0

画面の上部と画面の下部にいくつかのボタンの画像を表示したい。このコードを書きますが、画像が表示されません! どうすればこの問題を解決できますか? イメージを RelativeLayout の外に変換すると、イメージはページの上部に表示されますが、ビューはトップ ページの下部ページを分離したように表示されます。なんで?

ボタンに関する別の問題。btn4 ボタンは、別のボタンの上にささいなことを示していますか? なぜ?

<?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:background="@drawable/background">

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="0"
    android:layout_gravity="bottom">
     <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/smallyelowbar"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:layout_alignParentTop="true"/>
        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/background" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true">
        <Button android:id="@+id/btn1"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/more_selector"/>
        <Button 
            android:id="@+id/btn2"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/contact_selector"/>
        <Button android:id="@+id/btn3"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/product_selector"/>
        <Button android:id="@+id/btn4"
            android:layout_width="0dip"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:background="@drawable/introduce_selector"/>
        </LinearLayout>
</RelativeLayout>
</LinearLayout>
4

4 に答える 4

0

この XML を試してください

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

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/relative_btngroup"
        android:background="@drawable/ic_launcher" >

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:adjustViewBounds="true"
            android:scaleType="fitXY" />

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="fill_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/relative_btngroup"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <Button
            android:id="@+id/btn1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/btn2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/btn1" />

        <Button
            android:id="@+id/btn3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/btn2" />

        <Button
            android:id="@+id/btn4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/btn3" />
    </RelativeLayout>

</RelativeLayout>
于 2013-09-25T08:01:30.047 に答える
0

ここでの問題は、frameLayout が画像ビューと重なっているということです。これが、相対的なレイアウトから移動したときに機能する理由です。

以下のコードを試してください

<?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:background="@drawable/background">

<RelativeLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0"
android:layout_gravity="bottom">
    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@drawable/background" />
 <ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/smallyelowbar"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    android:layout_alignParentTop="true"/>


<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true">
    <Button android:id="@+id/btn1"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@drawable/more_selector"/>
    <Button 
        android:id="@+id/btn2"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@drawable/contact_selector"/>
    <Button android:id="@+id/btn3"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@drawable/product_selector"/>
    <Button android:id="@+id/btn4"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@drawable/introduce_selector"/>
    </LinearLayout>
</RelativeLayout>
</LinearLayout>
于 2013-09-25T08:08:04.020 に答える