2014-01-14 2 views
0

Im разработать один XML с некоторой кнопкой ее тонким шоу в целях XML https://www.dropbox.com/s/ao893440404e2gk/Untitled-1.png и эмуляторе, но кнопки смещения в устройстве (галактики подходят android2.3.6) https://www.dropbox.com/s/ux5st3x51q10p21/Untitled-2.png
, что я могу сделать?

это мой XML:кнопку Смещения после запуска в Android

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/back1" 
android:gravity="clip_vertical" 
tools:context=".Main" > 

<ImageButton 
    android:id="@+id/imageButton2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageButton1" 
    android:layout_below="@+id/imageButton1" 
    android:background="@null" 
    android:paddingBottom="5dp" 
    android:src="@drawable/btnmain2" /> 

<ImageButton 
    android:id="@+id/imageButton3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageButton2" 
    android:layout_below="@+id/imageButton2" 
    android:background="@null" 
    android:paddingBottom="5dp" 
    android:src="@drawable/btnmain3" /> 

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="126dp" 
    android:background="@null" 
    android:paddingBottom="5dp" 
    android:src="@drawable/btnmain1" /> 

<ImageButton 
    android:id="@+id/imageButton4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageButton3" 
    android:layout_below="@+id/imageButton3" 
    android:background="@null" 
    android:src="@drawable/btnmain4" /> 

ответ

0

Может быть, я неправильно понял, но если ваша цель состоит в том, чтобы расположить все кнопки в центре (independt от разрешение экрана):

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:layout_centerInParent="true" 
     android:orientation="vertical" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content"> 
      <Button/> 
      <Button/> 
      <Button/> 
      <Button/> 
    </LinearLayout> 
</RelativeLayout> 

Чтобы все ваши кнопки были выровнены по центру в RelativeLayout в содержании LinearLayout

Надеюсь, это поможет!

0

Похоже, он работает именно так, как вы создали его. Проблема возникает из кнопки 1, где вы указываете верхнее поле в провалах android:layout_marginTop="126dp" вместо вертикального центрирования. Лучшим решением является создание пустого 0-го уровня (или аналогичного базового элемента) с вертикальным центрированием, который затем будет располагаться вокруг других кнопок. Например:

У вас есть:

+----------------+ 
|    | 
| (button) | 
| (button) | 
| (button) | 
| (button) | 
|    | 
+----------------+ 

Что я предлагаю:

+----------------+ 
|    | 
| (button) | 
| (button) | 
|  (View)  | 
| (button) | 
| (button) | 
|    | 
+----------------+ 
Смежные вопросы