2

FrameLayoutのlayout_weightは0.13ですが、それよりはるかに大きいように見えます。なんで?多くの推奨事項はandroid:layout_height = "0dp"ですが、役に立ちません。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent" android:background="@drawable/background" android:weightSum="1">

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp" android:background="@drawable/bar_background" android:layout_weight="0.13">
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/header"
                android:id="@+id/textView" android:layout_gravity="center" android:textSize="@dimen/header_size"
                android:textColor="#ffffff" android:layout_marginTop="@dimen/header_margin_top" />
    </FrameLayout>
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <EditText
                android:inputType="text"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:id="@+id/textEdit"/>
        <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/imageView" android:layout_gravity="center" android:src="@drawable/separator"
                android:scaleType="fitXY"/>
        <ListView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/listView" android:layout_gravity="center" android:choiceMode="singleChoice"
                android:scrollingCache="false" android:cacheColorHint="#00000000"/>
    </LinearLayout>
</LinearLayout>
4

4 に答える 4

2

FrameLayout の兄弟に重みがないためだと思います。内側の LinearLayout に重み (おそらく .87) を追加してみて、問題が解決するかどうかを確認してください。

于 2013-02-15T21:57:21.753 に答える
1

申し訳ありませんが、IntelliJ IDEA のプレビュー バグのようです。すべてがデバイス上で良好です。皆さんありがとう。

于 2013-02-17T10:36:27.457 に答える
0
android:textSize="@dimen/header_size"

これは大きすぎるため、FrameLayoutを本来よりも大きくする必要があると思います

于 2013-02-16T00:23:53.907 に答える
0

私はあなたのレイアウトを試してみましたが、兄弟の LinearLayout に 0.87 の重みと 0dp の layout_height を設定した後、うまくいきました。FrameLayout の内側の TextView に設定している寸法が大きすぎる可能性がありますか?

于 2013-02-15T22:05:41.187 に答える