当用户触摸时,带有EditText的TextInputLayout正在减少

时间:2017-07-17 10:02:50

标签: java android xml android-layout

当我触摸这个地方时,带有EditText的TextInputLayout正在减少 我有2个问题,如果我想要相同大小的EditText,我应该修复什么,以及我应该为屏幕上的键盘添加什么。

enter image description here

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="pl.xd.hello.WeatherActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="6"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Podaj miejscowość" />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:gravity="center"
            android:orientation="horizontal">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/floatingActionButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                app:backgroundTint="@android:color/holo_red_dark"
                app:fabSize="mini"
                app:srcCompat="@drawable/ic_check_circle_black_24dp" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">

        <ListView
            android:id="@+id/weatherListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</LinearLayout>

1 个答案:

答案 0 :(得分:1)

对于您的第一个问题,请使用下面的// Taking String Builder to append all the String in one. StringBuilder sb = new StringBuilder(); for (String biyak : splitwords) { foo = (foo + "'" + biyak + "'" + foo1); String fot = foo.replaceAll(",$", " "); wordtv.setText(fot); Db1Backend db1Backend = new Db1Backend(GrammarActivity.this); // Append all your position into StringBuilder sb.append(db1Backend.getPOSbyWords(fot)); } postv.setText(sb.toString()); 来修复其父级尺寸

EditText

对于第二个问题,您应该在<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Podaj miejscowość" /> </android.support.design.widget.TextInputLayout> 文件中为您的活动添加android:windowSoftInputMode="stateAlwaysVisible",如下所示:

AndroidManifest.xml

这将为您的整个应用打开软键盘, 您可以查看this post了解更多信息。 但是如果你只想为这个<activity android:name=".MainActivity" android:label="@string/app_name" android:windowSoftInputMode="stateAlwaysVisible" /> activity打开键盘,你可以添加一个方法来手动打开键盘,如下所示:

fragment
相关问题