我對android開發比較陌生。我有一個TableLayout的活動。該活動的構建如下圖所示。將TableLayout中的單元格內容對齊到右邊
我希望兩個小按鈕在右邊,這樣既EditTexts可以使用完整的剩餘寬度。我也試圖設置「android:引力」像一些職位建議,但沒有任何影響。我怎麼做到這一點?
此外,我有兩個tableRows兩個行的信息,文本&按鈕。 活動的其餘部分不在任何tableRow中以獲取它們的全角。 這是常用的還是壞的編程?如果是這樣,那麼更好的方法是什麼?
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/strInputInfo"
android:id="@+id/lblHexToRGB"
android:layout_column="1" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/txtHexInput"
android:layout_column="1"
android:textCursorDrawable="@null"
android:hint="@string/strHexInputHint" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/strConvertButtonText"
android:id="@+id/cmdConvertCode"
android:layout_column="1"/>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/strRGBInfo"
android:id="@+id/lblRGBInfo"
android:layout_column="0" />
<EditText
android:layout_width="350px"
android:layout_height="wrap_content"
android:id="@+id/txtOutputRGB"
android:textCursorDrawable="@null"
android:layout_column="1"
android:textAlignment="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strButtonCopyText"
android:id="@+id/cmdCopyRGBToClipboard"
android:layout_column="2"
android:layout_gravity="right"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/strHexInfo"
android:id="@+id/lblHexInfo"
android:layout_column="0"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtOutputHex"
android:layout_column="1"
android:textAlignment="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strButtonCopyText"
android:id="@+id/cmdCopyHexToClipboard"
android:layout_column="2"/>
</TableRow>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_column="1"
android:maxHeight="100dp"
android:minHeight="100dp" />
</TableLayout>
太棒了!這對我很有用,謝謝! – Marcel