Сделайте неперекрывающуюся кнопку изображения с использованием относительного расположения - PullRequest
0 голосов
/ 24 марта 2012

Я спроектировал экран, используя эту относительную компоновку.

<?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" >

<AutoCompleteTextView
    android:id="@+id/EditText01"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true" />

<ImageButton
    android:id="@+id/imageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/EditText01"
    android:src="@android:drawable/ic_notification_clear_all" />

<AutoCompleteTextView
    android:id="@+id/EditText02"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/EditText01" />

<ImageButton
    android:id="@+id/imageButton2"
    android:layout_width="24dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/EditText02"
    android:src="@android:drawable/ic_notification_clear_all" />

Какие изменения я должен сделать, чтобы изображение выровнялось по правому краю для текстового поля автозаполнения. ??Заранее спасибо..PS: Так как у меня нет репутации, чтобы загрузить изображение. Вот ссылка http://i.stack.imgur.com/SRG9W.png

1 Ответ

0 голосов
/ 24 марта 2012

android:layout_alignRight="@+id/EditText01" означает, что ваша кнопка хочет, чтобы его правый край был выровнен с правым краем EditTexts. На самом деле вы хотите, чтобы левый край кнопок был выровнен по правому краю EditTexts. То есть android:layout_toRightOf="@+id/EditText01"

Изменить - это то, что вы хотите, я думаю,

<ImageButton
    android:id="@+id/imageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:src="@android:drawable/ic_notification_clear_all" />

<AutoCompleteTextView
    android:id="@+id/EditText01"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@id/imageButton1" />

<ImageButton
    android:id="@+id/imageButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/EditText01"
    android:src="@android:drawable/ic_notification_clear_all" />

<AutoCompleteTextView
    android:id="@+id/EditText02"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/EditText01"
    android:layout_below="@+id/EditText01"
 />
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...