2011-03-14 15 views
1

画面全体に画面が表示されなくなり、画面の下部にボタンが表示されなくなります。Android:画面全体が画面いっぱいに表示され、ボタンが下に表示されないのはなぜですか?

<?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"> 
<com.vig.comix.ImageZoomView 
    android:id="@+id/zoomview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_alignParentTop="true" /> 
<LinearLayout android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_below="@+id/zoomview" android:layout_alignParentBottom="true"> 
<ImageButton android:id="@+id/btnPrev" 
    android:layout_width="wrap_content"  android:layout_height="wrap_content" android:src="@android:drawable/ic_media_rew" 
    android:background="@null" 
    android:layout_weight="1" 
    android:width="0px" /> 
<ImageButton android:id="@+id/btnNext" 
    android:layout_width="wrap_content"  android:layout_height="wrap_content" android:src="@android:drawable/ic_media_ff" 
    android:background="@null" 
    android:layout_weight="1" 
    android:width="0px" /> 
<ImageButton android:id="@+id/btnMove" 
    android:layout_width="wrap_content"  android:layout_height="wrap_content" android:src="@android:drawable/btn_star" 
    android:background="@null" 
    android:layout_weight="1" 
    android:width="0px" /> 
<ImageButton android:id="@+id/btnDelete" 
    android:layout_width="wrap_content"  android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_delete" 
    android:background="@null" 
    android:layout_weight="1" 
    android:width="0px" /> 
</LinearLayout> 
</RelativeLayout> 

コードを変更してボタンを上に置くと、正常に動作します。私は相対レイアウト、線形レイアウト、ラウアウトウェイトを試しました...

私は間違っていますか?

+1

レイアウトを確認できるように投稿してください。 –

答えて

0

代わりにアンドロイドを置きます。それを削除して、ImageZoomView内に

を入れてみてください。もちろん、LinearLayoutに同じIDを与えます。

+0

Yay!それがうまくいったのですが、私の次の質問はなぜですか? –

+0

私はあなたにそれを伝えたいと思うが、私が知っている唯一のことは、私自身も同じ問題を抱えているということだ。そして、それを修正する唯一のことは、下から上にレイアウトを構築することです。要素を上下に並べるのではなく、互いの上に重ねて配置します。 –

+0

アイテムはxmlファイルの順序でレンダリングされるので、他のものがそれらをカバーしています。 idを先に参照する必要があるが、後でレイアウトでビューを必要とする場合は、+ idを使用する代わりに、常にリソースxmlファイルにアイテムIDを追加することができます。 – schwiz

0

おそらくlayout_weightが問題を引き起こしていますか?また、アイテムを相対的な位置にするオブジェクトを与えているようには見えませんか?

+0

申し訳ありませんが、コードを正しく書式設定できないようです。 android:layout_below = "@ + id/zoomview"節は線形レイアウトとは関係がありませんか? –

+0

ああ、ごめんなさい。相対的な位置はうまく見えます。 weightパラメータを使用しているので、イメージボタンの幅を0dipに設定する必要があります(水平に伸ばしたいので) – Kurru

0

変更この:これに

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

:あなたのLinearLayoutにlayout_below:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
+0

これは何も変わりません。相対レイアウトが親全体を占めるようにしたくないのですか?私が親全体を占めたくないのはズームビューです。 –

1

RelativeLayoutは扱いにくい場合があります。私はFrameLayoutLinearLayoutに固執しようとします。ここで私はあなたのケースで使用するレイアウトのスケッチです:言及していないとき

<LinearLayout orientation="vertical"> 
    <ImageZoomView layout_weight="1" layout_height="wrap_content"> 
    <LinearLayout orientation="horizontal" layout_height="wrap_content"> 
     ... buttons ... 
    </LinearLayout> 
</LinearLayout> 

高さと幅はfill_parentです。 ImageZoomViewlayout_weight属性は、下部ボタンを押しつぶすことなくできるだけ拡大させます。

+0

このソリューションも機能しました。私は前にとても近かった。 Zoomviewではなく、ボタンの線形レイアウトにlayout_weightを配置しました。私がズームビューの両方に置くと、それは機能します。 –

+0

LinearLayoutsはあまり複雑ではありません。私だけかもしれない。 –

関連する問題