2011-02-15 33 views
0

Hy!如何選擇合適的圖片尺寸

我在視圖上有兩張圖片,在按鈕上有一個按鈕。

但問題是,最後一張照片是在按鈕上畫的,而不是在第一張照片下。所以buttom上的按鈕是不可見的。

Screenshot

XML:

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical"> 
    <TextView android:layout_height="wrap_content" android:id="@+id/mainscreen" android:layout_width="fill_parent" android:text="Selected Channel" android:gravity="center"></TextView> 
    <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> 
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/mainscreen_state"></TextView> 
    <ImageView android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_height="wrap_content" android:id="@+id/ImageAd" android:layout_gravity="center"></ImageView> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent"> 


    <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/mainscreen_btchange" 
     android:text="Change State"></Button> 


    </RelativeLayout> 
    </LinearLayout> 

回答

0

試試這個

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

    <RelativeLayout 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_alignParentTop="true"> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:orientation="vertical"> 
     <TextView 
     android:layout_height="wrap_content" 
     android:id="@+id/mainscreen" 
     android:layout_width="fill_parent" 
     android:text="Selected Channel" 
     android:gravity="center"></TextView> 
     <ImageView 
     android:id="@+id/ImageView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"></ImageView> 
     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/mainscreen_state"></TextView> 
     <ImageView 
     android:layout_width="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_height="wrap_content" 
     android:id="@+id/ImageAd" 
     android:layout_gravity="center"></ImageView> 
    </LinearLayout> 
    </RelativeLayout> 
    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true" 
    > 
    <Button 
     android:layout_width="wrap_content" 
     android:text="Change State" 
     android:layout_height="wrap_content" 
     android:id="@+id/mainscreen_btchange" 
     android:layout_centerHorizontal="true"></Button> 

    </RelativeLayout> 
</RelativeLayout> 
0

你在錯誤的地方打開RelativeLayout的,所以,唯一的事情裏面 你之前應該把它和使用一些android:layout_below屬性來選擇按鈕所有元素的正確位置

有很多方法可以創建佈局,如果你想使用RelativeLayout你必須以正確的方式使用它。正確的方法是在其中放置2個或更多視圖,並使用屬性android:layout_below或類似屬性來告訴,其中一個對象的位置與另一個對象的位置相對。

例如,你想第一個圖像超過第二個?你已經把它們放在同一個相對佈局,並把第二圖像中的一個屬性android:layout_below="@id/1st_image_id"

+0

的RL需要在底部 – user547995 2011-02-15 14:58:04