EditText окно высоты вопроса андроид - PullRequest
4 голосов
/ 26 июля 2011

У меня есть linearlayout, в котором у меня одно изображение, одно textview, два edittext и кнопка.

Когда я запускаю свое приложение в эмуляторе или на моем устройстве, высота edittexts кажется больше по размеру, скорее они должны быть однострочными edittext ящиками..xml

<?xml version="1.0" encoding="utf-8"?>
<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="@android:color/white">
    <TextView android:id="@+id/item_blank" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:padding="2dp" 
        android:textSize="14dp" 
        android:textColor="@android:color/black"
        android:background="@android:color/white" 
        android:text=" "/>
    <ImageView android:id="@+id/test_image" 
        android:src="@drawable/logo_infraline_energy"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center"/>
    <TextView android:id="@+id/item_title" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:padding="2dp" 
        android:textSize="14dp" 
        android:textColor="@android:color/black"
        android:background="@android:color/white" 
        android:text="Please put in your valid credentials to get access."/>
    <EditText android:id="@+id/userName" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:inputType="textEmailAddress" 
        android:layout_weight="1" 
        android:height="30dp"
        android:hint="Email Address" />
    <EditText android:id="@+id/password" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_weight="1"
        android:hint="Password"
        android:height="30dp" 
        android:password="true" />
    <Button android:id="@+id/loginButton" 
        android:text="Login"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:onClick="login" />
</LinearLayout>

Ответы [ 4 ]

10 голосов
/ 26 июля 2011

Удалить строку:

андроида: layout_weight = "1"

из обоих EditTexts и ваших EditTexts будут одинарными. Приветствия.

4 голосов
/ 26 июля 2011

Это потому, что вы присвоили вашему EditText вес 1. Это говорит родительскому LinearLayout увеличивать EditText, чтобы заполнить оставшееся пустое пространство. Просто уберите вес = 1 и все будет в порядке:)

1 голос
/ 26 июля 2011

просто поставьте android:layout_height="20px" вместо android:layout_height="wrap_content".

и удалите android:layout_weight="1"

посмотрите, изменится ли editText по размеру.

1 голос
/ 26 июля 2011

это вес = 1, а также рост = 30px.Layout_height = wrap_content подрывается весом = 1 и ростом = 30px.избавиться от обоих, и вы получите желаемый макет

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