0

以下のようにレイアウトを作成していますが、チェックボックス要素が画面に表示されません。どこが間違っていますか?

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

    <LinearLayout android:orientation="horizontal" 
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <SeekBar android:id="@+id/seek" 
            android:layout_width="300dip"
            android:layout_height="wrap_content" 
            android:progress="50"/>

        ...and a few more elements here.

    </LinearLayout>

    <CheckBox android:id="@+id/CheckBox" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:text="somestring" />

</LinearLayout>
4

5 に答える 5

1

LinearLayout前の の高CheckBoxさは に設定されMATCH_PARENT(親のすべての高さを埋めます)、両方の親LinearLayoutの向きは垂直に設定されているため、CheckBoxは画面から押し出されます。

たとえば、をLinearLayout含むの高さを設定します。SeekBarWRAP_CONTENT

于 2012-08-24T06:22:48.340 に答える
0

これを試して :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="10" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="9"
    android:orientation="horizontal" >

    <SeekBar
        android:id="@+id/seek"
        android:layout_width="300dip"
        android:layout_height="wrap_content"
        android:progress="50" />
</LinearLayout>

<CheckBox
    android:id="@+id/CheckBox"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="somestring" />

</LinearLayout>
于 2012-08-24T06:35:21.073 に答える
0

レイアウトで、サイズを柔軟にしたい要素を 1 つ選択します (高さなど)。次に、そのheight="0dp"とを作成しweight="1"ます。残りの要素の高さを作成: height="wrap_content".

また、他の要素にいくつかの dp の控えめなサイズを指定した可能性があるため、それらの合計の高さが使用可能な画面スペースを使い果たしているか、画面の高さを超える要素が多すぎます。この場合、レイアウトを でラップしますScrollView

于 2012-08-24T06:47:01.337 に答える
0

LinerLayout の定義を android:layout_height="match_parent" にすることはできません

<LinearLayout android:orientation="horizontal" 
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1">

linearlayout に match_parent を設定すると、すべてのコンテンツが消費されるため、wrap_content の方が優れています。しかし、私が書いたように設定すると、チェックボックスが一番下のページになり、linearlayoutが画面の残りの部分を消費します。

于 2012-08-24T06:27:43.047 に答える
0

コンテンツをラップするには、内側の Linear Layout の高さと幅を設定する必要があります。これを試して。

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

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <SeekBar
            android:id="@+id/seek"
            android:layout_width="300dip"
            android:layout_height="wrap_content"
            android:progress="50" />
    </LinearLayout>

    <CheckBox
        android:id="@+id/CheckBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="somestring" />

</LinearLayout>
于 2012-08-24T06:33:32.337 に答える