1

カードビュー内の右側にイメージビューを設定したいのですが、整列が機能していません...提案してください

レイアウト

  <FrameLayout
    android:id="@+id/framelayout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/lin1"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <android.support.v7.widget.CardView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="05dp"
            android:layout_marginTop="15dp"
            android:id="@+id/casardviewvisit">
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#482048"
                    android:orientation="horizontal">
                <ImageView
                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"
                    android:src="@drawable/omg"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="20dp"
                    android:textColor="#fff"
                    android:textStyle="bold"
                    android:layout_marginLeft="20dp"
                    android:layout_gravity="center"
                    android:text="Add Order"/>

                    <ImageButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/sent"
                        android:layout_gravity="right"
                        android:id="@+id/imageButtsdon" />
                </LinearLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>
  </framelayout>

このように私は試していますが、機能していません。なぜこれが機能していないのかわかりません

4

7 に答える 7

0

実行して TextView を引き伸ばします

android:layout_width="0dp"
android:layout_weight="1"
于 2016-12-12T07:26:36.693 に答える
0

次のコードを使用できます。

  <android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"

    android:layout_height="wrap_content"
    android:layout_marginLeft="05dp"
    android:layout_marginTop="15dp"
    android:id="@+id/casardviewvisit">

    <LinearLayout
        android:weightSum="1"
        android:gravity="center"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#482048"
        android:orientation="horizontal">
        <ImageView
            android:layout_weight=".2"
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:src="@drawable/test"/>
        <TextView
            android:layout_weight=".5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:textColor="#fff"
            android:textStyle="bold"
            android:layout_marginLeft="20dp"
            android:layout_gravity="center"
            android:text="Add Order"/>

        <ImageView
            android:layout_weight=".2"
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:src="@drawable/test"
            android:layout_gravity="right"
            android:id="@+id/imageButtsdon" />
    </LinearLayout>
</android.support.v7.widget.CardView>

xmlファイルにコピーして貼り付けることができます

于 2016-12-12T07:27:25.617 に答える
0

以下のxmlを確認してください。

<FrameLayout
        android:id="@+id/framelayout"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/lin1"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
            <android.support.v7.widget.CardView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="05dp"
                android:layout_marginTop="15dp"
                android:id="@+id/casardviewvisit">
                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:background="#482048"
                        android:orientation="horizontal">

                   <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="fill_parent"
                        android:layout_weight="1"
                        android:background="#482048"
                        android:orientation="horizontal">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="20dp"
                        android:textColor="#fff"
                        android:textStyle="bold"
                        android:layout_marginLeft="20dp"
                        android:layout_gravity="center"
                        android:text="Add Order"/>

                    <ImageButton
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@drawable/sent"
                            android:layout_gravity="right"
                            android:id="@+id/imageButtsdon" />
                    </LinearLayout>
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/omg"/>
                    </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>
      </framelayout>
于 2016-12-12T07:34:29.967 に答える
0

画像ビューには単純な重力を使用してください。

<FrameLayout
    android:id="@+id/framelayout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/lin1"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <android.support.v7.widget.CardView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="05dp"
                android:layout_marginTop="15dp"
                android:id="@+id/casardviewvisit">
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#482048"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="20dp"
                        android:textColor="#fff"
                        android:textStyle="bold"
                        android:layout_marginLeft="20dp"
                        android:layout_gravity="center"
                        android:text="Add Order"/>

                    <ImageButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/sent"
                        android:layout_gravity="right"
                        android:id="@+id/imageButtsdon" />
                </LinearLayout>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_gravity="end"
                    android:layout_height="match_parent"
                    android:layout_marginRight="16dp"
                    android:src="@drawable/omg"/>
            </android.support.v7.widget.CardView>
        </LinearLayout>
    </LinearLayout>
</FrameLayout>
于 2016-12-12T07:28:09.010 に答える
0

以下に示すように、Cardview 内では、コンテナ LinearLayout は Weightsum に 1 を与え、Imageview に .25 の重みを、textview に .5 の重みを与えます。

    <android.support.v7.widget.CardView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/casardviewvisit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="05dp"
            android:layout_marginTop="15dp" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#482048"
                android:orientation="horizontal"
                android:weightSum="1" >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".25"
                    android:src="@drawable/omg" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="20dp"
                    android:layout_weight=".5"
                    android:text="Add Order"
                    android:textColor="#fff"
                    android:textSize="20dp"
                    android:textStyle="bold" />

                <ImageButton
                    android:id="@+id/imageButtsdon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right"
                    android:layout_weight=".2"
                    android:src="@drawable/sent" />
            </LinearLayout>
    </android.support.v7.widget.CardView>
于 2016-12-12T07:55:21.147 に答える