क्या मैं ऐसा ही कुछ पाने के लिए क्या करना होगा:एंड्रॉयड: TableLayout प्रथम स्तंभ का दाएँ, दूसरा छोड़ दिया
मैं यह कर सकता HTML में समस्याओं के बिना लेकिन कैसे एंड्रॉयड में?
क्या मैं ऐसा ही कुछ पाने के लिए क्या करना होगा:एंड्रॉयड: TableLayout प्रथम स्तंभ का दाएँ, दूसरा छोड़ दिया
मैं यह कर सकता HTML में समस्याओं के बिना लेकिन कैसे एंड्रॉयड में?
आपके TableLayout
के कॉलम में आपको सामग्री प्रदर्शित करने के लिए TextView
का उपयोग करना होगा।
तो पहले कॉलम के लिए यह कोशिश,
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Key"
android:textColor="@android:color/black"/>
और दूसरे स्तंभ के लिए यह कोशिश,
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Value"
android:textColor="@android:color/black"/>
प्राप्त कर सकते हैं यह काम करता है, धन्यवाद। लेकिन कोशिकाओं चौड़ाई के बराबर नहीं हैं (वे 50% (पहले) और 50% (दूसरा) होना चाहिए)। –
@DarioRossi वेन्की द्वारा दिखाया गया कोड सही है। उसके/उसके कोड में क्या समस्या है? –
Use TextViews and gravity
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="value" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="More key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="More value" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Even more key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="Even more value" />
</TableRow>
</TableLayout>
यह काम करता है। लेकिन एक और समस्या है। तालिका में कोशिकाओं की चौड़ाई बराबर होनी चाहिए (मान लीजिए 50%) लेकिन वास्तव में उनके पास 33% (पहले) और 66% (दूसरा) है। –
पहले टेक्स्ट व्यू wight = 1 लिखें और दूसरा टेक्स्ट व्यू wight = 2 – Venky
Write first TextView wight=1 and second TextView wight=2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="left"
android:text="value" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="More key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="left"
android:text="More value" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Even more key" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="left"
android:text="Even more value" />
</TableRow>
</TableLayout>
</LinearLayout>
मैं नहीं कर सकते अपनी छवि देखते हैं क्योंकि ristriction का यहाँ अपने xml कॉपी। तो विचार –