你如何降低浮动EDITTEXT暗示,EDITTEXT框在Android中的空间? [英] How do you reduce space between floating editText hint and editText box in Android?
本文介绍了你如何降低浮动EDITTEXT暗示,EDITTEXT框在Android中的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个浮动提示一个EditText,但我不知道我怎么会减少浮动提示和的EditText框之间的空间。
现在我的UI看起来像 http://imgur.com/9hQzzx4 ,我想,以减少标题之间的空间浮动提示和的EditText框。
这里的code到我的xml文件
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直> < android.support.v7.widget.Toolbar
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
安卓了minHeight =?ATTR / actionBarSize
机器人:ATTR / colorPrimary背景=
应用:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Light> < /android.support.v7.widget.Toolbar> < android.support.design.widget.TextInputLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =16DP
机器人:layout_marginLeft =16DP
机器人:layout_marginRight =16DP> <的EditText
风格=@风格/ Widget.AppCompat.EditText
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:TEXTSIZE =40dp
机器人:提示=标题/> < /android.support.design.widget.TextInputLayout> < android.support.design.widget.TextInputLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =16DP
机器人:layout_marginRight =16DP> <的EditText
风格=@风格/ Widget.AppCompat.EditText
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:TEXTSIZE =32dp
机器人:提示=详细信息/> < /android.support.design.widget.TextInputLayout>< / LinearLayout中>
解决方案
的EditText元素上只需设置paddingTop属性。
< android.support.design.widget.TextInputLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT> <的EditText
机器人:ID =@ + ID / PLACE_NAME
安卓的inputType =TEXT
机器人:提示=@字符串/名
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:paddingTop =0dp/>< /android.support.design.widget.TextInputLayout>
I have an EditText with a floating hint but I was wondering how I would reduce the space between the floating hint and the EditText box.
Right now my UI looks like http://imgur.com/9hQzzx4 and I want to reduce the space between the "Title" floating hint and the EditText box.
Here's the code to my xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<EditText
style="@style/Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
android:hint="Title"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<EditText
style="@style/Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="32dp"
android:hint="Details"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
解决方案
Just set paddingTop attribute on EditText element.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/place_name"
android:inputType="text"
android:hint="@string/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="0dp"/>
</android.support.design.widget.TextInputLayout>
这篇关于你如何降低浮动EDITTEXT暗示,EDITTEXT框在Android中的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文