-1

内部にテーブル レイアウトを持つ CardView があります。私のテーブル レイアウトでは、行の右端にテキスト ビューを表示したいと考えています。

私のxml

<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        card_view:cardUseCompatPadding="true"
        app:cardElevation="@dimen/cardView_elevation"
        app:cardCornerRadius="@dimen/cardView_radius"
        card_view:cardBackgroundColor="@color/cardView_background">
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="10dp" android:layout_marginBottom="10dp">
            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/row_background"
                android:padding="2dp">
                <TextView
                    android:text="Under Weight"
                    style="@style/RowLabel" android:textColor="@android:color/holo_orange_light"/>
                <TextView
                    android:text="&lt;18.5"
                    style="@style/RowVal" android:textColor="@android:color/holo_orange_light"/>
            </TableRow>

...上記と同じ他の行

私のスタイル:

<style name="RowLabel" parent="@android:style/TextAppearance">
    <item name="android:textSize">14.0sp</item>
    <item name="android:paddingLeft">10.0dip</item>
    <item name="android:paddingRight">20.0dip</item>
</style>
<style name="RowVal" parent="@android:style/TextAppearance">
    <item name="android:textSize">14.0sp</item>
    <item name="android:paddingLeft">20.0dip</item>
    <item name="android:paddingRight">10.0dip</item>
</style>

写真:

ここをクリック

4

2 に答える 2

0

ステップ 1:.Xml ファイルを作成する

<LinearLayout style="@style/summaryField">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1.60">

                    <TextView
                        android:id="@+id/tv_lname_summary"                           
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_marginLeft="10dp"
                        android:gravity="center_vertical" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="2.40">

                    <TextView
                        android:id="@+id/tv_getlname_summary"                            
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="3"
                        android:background="@color/userDataColor"
                        android:gravity="center_vertical" />

                </LinearLayout>

            </LinearLayout>

ステップ 2 :styles.xml でスタイルを作成する

 //Advert Summary Screen
    <style name="summaryField">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:weightSum">4</item>
    </style>
于 2016-07-04T08:54:35.577 に答える
0

これを試して :

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="&lt;18.5"
                android:layout_weight="1"
                android:gravity="right"
                android:textColor="@android:color/holo_orange_light" />
于 2016-07-04T09:19:08.610 に答える