0

これが単純なものであることを願っています

同じ行に 2 つのテキストビューを左揃えで配置したい。

現在、私のレイアウトは次のとおりです。

ここに画像の説明を入力

このレイアウトが必要です(ペイントで図を変更したことに注意してください):

ここに画像の説明を入力

ここに私が現在持っているxmlがあります:

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView
    android:id="@+id/txtSetItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:layout_weight="2" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:focusableInTouchMode="false"
    android:clickable="false"
    android:focusable="false"/>



<CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusableInTouchMode="false"

    android:focusable="false" />

<TextView
    android:id="@+id/txtSetAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView"
    android:focusableInTouchMode="false"
    android:clickable="false"
    android:focusable="false" />



<TextView
    android:id="@+id/txtSetPrice"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" 
    android:focusableInTouchMode="false"
    android:clickable="false"
    android:focusable="false"/>

4

5 に答える 5

0

最初のTextViewの重みを0(または1より小さいもの)に変更します。あなたはそれらに等しい重みを与えており、LinearLayoutはそれらに等しい幅を与える方法でそれらを配置しますが、それはあなたが望むものではありません。

于 2013-03-13T21:47:19.693 に答える
0

うーん、レイアウトはコンパイルしないでくださいandroid:layout_width。TextViewオブジェクトには属性がありません。

これを修正するには、削除layout_weightしてに設定layout_widthしますwrap_content

とにかく、ここで:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView  
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="This"
/>
<TextView  
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="this"
/>
</LinearLayout>
于 2013-03-13T21:47:40.723 に答える
0

これにより、探しているものが得られます。

<LinearLayout 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"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This"
        android:paddingLeft="10dp" />

</LinearLayout>
于 2013-03-13T21:51:47.797 に答える