2014-11-05 99 views
0

在我的應用我想以這種方式設置的ImageButton的在一個位置安卓:ImageButton的一個動態的大小和位置固定

enter image description here

,我想用這種方式爲所有的屏幕適應這個按鈕,是有獲得它的策略?

+0

你想添加ImageButton的佈局有多少?將每個佈局的根設置爲Relative,並製作一個單獨的頁腳佈局, ImageButton..U需要在每個佈局中包含頁腳.. :) – TheFlash 2014-11-05 13:17:00

回答

0

這取決於你有多少的屏幕具有應有這個按鈕,他們如何相互交流,以及按鈕是否應該有相同的基礎每個屏幕都有一個離子,但是一個選擇是隻有一個帶有佈局的Activity,其中底部有按鈕,按鈕上方有一個空的佈局,作爲片段容器。而不是爲新的「屏幕」開始新的活動改變這個容器中的碎片。按鈕總是在同一個地方,你可以在活動中集中處理它的onClick ...

0

使用

android:align = "Center" 

android:width ="0dp" 
android:weight = "1" 
+0

在大屏幕上沒問題,但在小屏幕上,ImageButton非常大!用於小屏幕的 – CrazyDev 2014-11-05 13:21:01

+0

將低像素圖像放在具有相同名稱的drawable-mdpi文件夾中。 – DJhon 2014-11-05 13:27:24

+0

但在android中可以使用一個圖像作爲所有設備的項目... – CrazyDev 2014-11-05 13:30:44

0

BPut的ImageView在RelativeLayout並設置ATTRS對於這樣的圖像視圖:

<RelativeLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
     <ImageView 
      android:id="@+id/previewImage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true"/> 
</RelativeLayout>