Android-макет - делает некоторые объекты расширяемыми

1

Учитывая горизонтальный LinearLayout в Android, я бы хотел создать:

(1) текстовое поле, которое заполняет почти ширину экрана, за исключением выделения достаточно места для...

(2) кнопка справа

Итак, я создаю EditText и Button, и они оба очень маленькие.

 <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
 <EditText android:text="" 
   android:id="@+id/Text01"
   android:layout_height="wrap_content"
   android:layout_width="wrap_content">
 </EditText>
 <Button android:text="+"
   android:id="@+id/Button01"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="right">
 </Button>
 </LinearLayout>

Я не могу установить EditText для android: layout_width = "fill_parent", иначе он стирает кнопку. Итак, как сделать EditText как можно больше?

Теги:
android-widget

1 ответ

1
Лучший ответ
<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
 <EditText android:text="" 
  android:id="@+id/Text01"
  android:layout_width ="wrap_content"
  android:layout_height="wrap_content"
  android:layout_weight="1">
 </EditText>
 <Button android:text="+"
  android:id="@+id/Button01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="right">
 </Button>
 </LinearLayout>
  • 1
    «Ошибка: недопустимые целочисленные типы (в« layout_width »со значением« 0 »)»
  • 0
    так что измени его на 0dip
Показать ещё 4 комментария

Ещё вопросы

Сообщество Overcoder
Наверх
Меню