【发布时间】:2018-07-22 22:56:04
【问题描述】:
无论我做什么,我的 EditText 都是这样的:
我的 XML:
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout_search"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_gravity="top"
android:gravity="top"
android:layout_height="wrap_content">
<EditText
android:background="@null"
android:textColor="@color/black"
android:layout_centerInParent="true"
android:gravity="top"
android:layout_gravity="top"
android:id="@+id/SearchText"
android:textColorLink="@color/black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/normatext"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
我在所有可能的变化中更改了gravity 和layout_gravity 的所有可能值!有什么想法吗?
编辑: 完整版面:
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="0dp"
android:paddingTop="6dp"
android:paddingBottom="5dp"
android:layout_margin="3dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_height="45dp">
<Button
android:layout_width="43dp"
android:layout_height="wrap_content"
android:background="@drawable/ham"
android:id="@+id/hambtn"
android:textColorHint="@color/black"
android:layout_weight="0"
/>
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout_search"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_gravity="top"
android:gravity="top"
android:layout_height="wrap_content">
<EditText
android:background="@null"
android:textColor="@color/black"
android:layout_centerInParent="true"
android:gravity="top"
android:layout_gravity="top"
android:id="@+id/SearchText"
android:textColorLink="@color/black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/normatext"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="55dp"
android:layout_weight="0"
android:layout_height="match_parent"
android:background="@drawable/my_button_bg"
android:text="news"
android:id="@+id/newsbtn"
android:layout_marginLeft="8dp"
android:layout_marginRight="6dp"
android:paddingBottom="5dp"
/>
</LinearLayout>
【问题讨论】:
-
你的完整布局 xml 文件是什么?另外,您稍后在 java 中修改视图吗?
-
好的,已编辑...
-
想出了一些调查方法,尝试其中一些并更新?
标签: android-layout android-edittext