0

現在、細かいUIに取り組んでいます。今、私はこれに来ました: ここに画像の説明を入力

マフィンが入った左側の「profile_layout」にこだわっています。右側の 2 つのバーについては、wrap_content を使用しています。

しかし、今は profile_layout が 2 つのバーからの「wrap_content」の高さ全体を使用できるようにすることにこだわっています。

これを解決する方法はありますか?

これが私のコードです:

<RelativeLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:background="@color/colorPrimaryDark"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:padding="8dp"
xmlns:app="http://schemas.android.com/tools">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@null"
    >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@null"
        >
        <android.support.v7.widget.CardView
            android:id="@+id/profile_layout"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#ffffff"
            >

            <com.pkmmte.view.CircularImageView
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:src="@drawable/muffin"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="20dp"
                android:background="@null"
                app:border="true"
                app:border_color="#EEEEEE"
                app:border_width="4dp"
                app:shadow="true"
                />

            <TextView
                android:textColor="#212121"
                android:layout_gravity="bottom|center_horizontal"
                android:layout_marginBottom="10dp"
                android:text="Muffin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                />

            </android.support.v7.widget.CardView>
    </RelativeLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        >
        <android.support.v7.widget.CardView
            android:id="@+id/hp_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="4dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#ffffff"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@null"
                android:padding="3dp"
                >
                <TextView
                    android:id="@+id/hp_text"
                    android:textColor="#212121"
                    android:textSize="11sp"
                    android:text="HP"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="2dp"
                    android:layout_marginLeft="2dp"
                    android:background="@null"
                    />
                <ProgressBar
                    android:id="@+id/hp_bar"
                    android:layout_width="match_parent"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_height="20dp"
                    android:progress="43"
                    android:progressDrawable="@drawable/hp_bar"
                    android:background="@null"
                    />
                <TextView
                    android:id="@+id/hp_currently"
                    android:textColor="#212121"
                    android:textSize="13sp"
                    android:text="43/100"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:layout_marginLeft="2dp"
                    android:background="@null"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>
        <android.support.v7.widget.CardView
            android:id="@+id/mp_bar_layout"
            android:layout_below="@id/hp_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="4dp"
            card_view:cardCornerRadius="2dp"
            card_view:cardElevation="2dp"
            card_view:cardBackgroundColor="#ffffff"
            >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@null"
                android:padding="3dp"
                >
                <TextView
                    android:id="@+id/mp_text"
                    android:textColor="#212121"
                    android:textSize="11sp"
                    android:text="MP"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="2dp"
                    android:layout_marginLeft="2dp"
                    android:background="@null"
                    />
                <ProgressBar
                    android:id="@+id/mp_bar"
                    android:layout_width="match_parent"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_height="20dp"
                    android:progress="17"
                    android:progressDrawable="@drawable/mp_bar"
                    android:background="@null"
                    />
                <TextView
                    android:id="@+id/mp_currently"
                    android:textColor="#212121"
                    android:textSize="13sp"
                    android:text="17/100"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:layout_marginLeft="2dp"
                    android:background="@null"
                    />
            </LinearLayout>
        </android.support.v7.widget.CardView>
    </RelativeLayout>
</LinearLayout>

4

3 に答える 3

0

muffin-layout_height を含む cardview を match_parent に変更します。それで解決しない場合はコメントしてください

編集:わかりましたので、もう少し考えた後、相対レイアウトがここで問題を引き起こしていることがわかりました。ここで、相対レイアウトを完全に削除するか、線形レイアウトに置き換えることができます。最後に、問題を修正するには、カードビューの高さが match_parent である必要があり、その直接の親 (囲んでいるタグ) は、高さが wrap_content の相対レイアウト以外のものでなければなりません。

于 2016-03-19T00:20:31.833 に答える
0

次のように LinearLayouts を使用する必要があります。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/card_background_selector"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"> <!-- You may give a definite value too -->

    <ImageView
        android:padding="@dimen/icon_padding_large"
        android:src="@mipmap/ic_launcher"
        android:layout_weight="3"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:id="@+id/appIcon" />

    <LinearLayout
        android:padding="@dimen/icon_padding_large"
        android:orientation="vertical"
        android:layout_weight="7"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

        <TextView
            android:singleLine="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="New Text"
            android:id="@+id/appName" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Small Text"
            android:id="@+id/appDeveloper" />
    </LinearLayout>
</LinearLayout>
于 2016-03-19T00:54:15.420 に答える