मेरे पास नीचे एक बटन के साथ एक टेबललाउट है। मेरी समस्या यह है कि बटन कॉलम की पूरी चौड़ाई को भरने के लिए फैला हुआ है, भले ही मैं इसे चौड़ा नहीं चाहता।एंड्रॉइड टेबललेआउट में बटन चौड़ाई
एक्सएमएल इस तरह दिखता है:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:stretchColumns="*"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableRow android:layout_height="wrap_content"
android:layout_width="fill_parent">
<CheckBox android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some text 1"/>
<CheckBox android:id="@+id/check2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some text 1"/>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="fill_parent">
<CheckBox android:id="@+id/check3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Even some more text 2"/>
<CheckBox android:id="@+id/check4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Even some more text 2"/>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="fill_parent">
<CheckBox android:id="@+id/check5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="An even longer line of text 3"/>
<CheckBox android:id="@+id/check6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Another longer line of text 3"/>
</TableRow>
<EditText
android:id="@+id/myEditText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:singleLine="false"
android:text="Enter some text"
/>
<TableRow>
<Button android:id="@+id/SaveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save">
</Button>
</TableRow>
</TableLayout>
यहां तक कि अगर मैं बटन यह ध्यान नहीं देता का सुस्पष्ट चौड़ाई निर्धारित किया है। उदाहरण के लिए अगर मेरे पास है:
<Button android:id="@+id/SaveButton"
android:layout_width="100sp"
android:layout_height="100sp"
android:text="Save">
</Button>
... बटन लम्बे हो जाता है, लेकिन अभी भी चौड़ाई कॉलम भरने के लिए फैला है।
मैं चाहता हूं कि बटन कॉलम में केंद्रित वर्तमान की चौड़ाई के आधा हो। अग्रिम धन्यवाद !!
इस समाधान के साथ समस्या यह है कि, स्तंभ के भीतर बटन केंद्र के लिए मुश्किल है, तो बटन स्तंभ के बाहर है । –