Одна кнопка слева, другая справа - PullRequest
2 голосов
/ 19 сентября 2011

Я знаю, что есть вопросы, подобные этому, но в большинстве случаев кажется, что их проблема в том, что они не выровняли макеты в качестве заполнителя. Ну, я сделал так, я не уверен, почему мои кнопки все еще не делают этого. Может ли это быть из-за всех используемых мной макетов?

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/face">

  <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center">
  <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/eyes1" />
        <LinearLayout android:layout_marginTop="50dp"  android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
            <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" />
            <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right"></Button>
        </LinearLayout>
  </RelativeLayout>

</LinearLayout>

Наверное, что-то простое я тоже пропустил. Спасибо за любую помощь.

Ответы [ 3 ]

1 голос
/ 19 сентября 2011

попробуйте это

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/face">

  <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center">
  <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:background="@drawable/eyes1" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
        <RelativeLayout android:layout_marginTop="50dp"  android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
            <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true"/>
            <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right" android:layout_alignParentRight="true"></Button>
        </RelativeLayout>
  </RelativeLayout>

</LinearLayout>

Я просто изменил LinearLayout на Относительный макет и установил свойства на одну кнопку, чтобы высветить слева направо.

1 голос
/ 19 сентября 2011
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/face">

  <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center">
  <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/eyes1" />
            <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true"/>
            <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right" android:layout_alignParentRight="true"></Button>
  </RelativeLayout>

</LinearLayout>

попробуйте

0 голосов
/ 19 сентября 2011

Проверьте это: это подходящий пример для вашего требования.

http://androidcodesnips.blogspot.com/2011/09/showing-buttons-on-either-side-of.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...