android - EditText 在 Lollipop 下方以一种奇怪的方式显示

标签 android android-layout android-studio android-edittext

我的布局中有两个 EditText。问题是它在不同的 Android 版本中以一种奇怪的方式显示。
这就是它在 Android 4.1.1 Jellybean(Intex Aqua Wonder) 或 Lollipop 以下任何版本中的显示方式

IMAGE 1

这就是它在 Android 5.1 Lollipop(Moto E2) 中的显示方式

IMAGE 2

这是我的布局文件 edittext 的 ID 是 edt_title 和 edt_desc(用于搜索)。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ppv="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/logo_background"
tools:context="in.net.spectrum.frankstrade.SellActivity_2">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:title="@string/app_name"
            app:titleTextColor="@color/textColorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    </android.support.design.widget.AppBarLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="#F7F7F7"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:padding="@dimen/activity_horizontal_margin"
            android:weightSum="2">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:weightSum="2"
                android:layout_marginBottom="10dp"
                android:orientation="horizontal">

                <ImageView
                    android:id="@+id/imv_camera"
                    android:layout_width="wrap_content"
                    android:layout_height="150dp"
                    android:layout_weight="1"
                    android:src="@drawable/camera" />

                <ImageView
                    android:id="@+id/imv_gallery"
                    android:layout_width="wrap_content"
                    android:layout_height="150dp"
                    android:layout_weight="1"
                    android:src="@drawable/gallery" />
            </LinearLayout>

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

                <HorizontalScrollView
                    android:id="@+id/scroller"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:orientation="horizontal"
                        android:weightSum="2">

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="5dp"
                            android:orientation="vertical">

                            <android.support.v7.widget.CardView
                                android:id="@+id/img_cv1"
                                android:visibility="gone"
                                android:layout_width="150dp"
                                android:layout_height="150dp"
                                android:layout_marginBottom="5dp"
                                android:layout_marginTop="5dp"
                                android:background="@color/colorCardView"
                                app:cardCornerRadius="5dp">

                                <ImageView
                                    android:id="@+id/iv_photo1"
                                    android:layout_width="150dp"
                                    android:layout_height="150dp"
                                    android:layout_marginRight="5dp"
                                    android:padding="3dp"
                                    android:background="@drawable/border" />


                            </android.support.v7.widget.CardView>

                            <ProgressBar
                                android:id="@+id/progress"
                                android:layout_width="150dp"
                                android:layout_height="30dp"
                                android:layout_gravity="bottom|center_horizontal"
                                android:indeterminate="true" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="5dp"
                            android:orientation="vertical">

                            <android.support.v7.widget.CardView
                                android:id="@+id/img_cv2"
                                android:layout_width="150dp"
                                android:layout_height="150dp"
                                android:layout_marginTop="5dp"
                                android:background="@color/colorCardView"
                                android:visibility="gone">

                                <ImageView
                                    android:id="@+id/iv_photo2"
                                    android:layout_width="150dp"
                                    android:layout_height="150dp"
                                    android:layout_marginRight="5dp"
                                    android:padding="3dp"
                                    android:background="@drawable/border" />

                            </android.support.v7.widget.CardView>

                            <ProgressBar
                                android:id="@+id/progress2"
                                android:layout_width="150dp"
                                android:layout_height="30dp"
                                android:layout_gravity="bottom|center_horizontal"
                                android:indeterminate="true" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="5dp"
                            android:orientation="vertical">

                            <android.support.v7.widget.CardView
                                android:id="@+id/img_cv3"
                                android:layout_width="150dp"
                                android:layout_height="150dp"
                                android:layout_marginTop="5dp"
                                android:background="@color/colorCardView"
                                android:visibility="gone">

                                <ImageView
                                    android:id="@+id/iv_photo3"
                                    android:layout_width="150dp"
                                    android:layout_height="150dp"
                                    android:layout_marginRight="5dp"
                                    android:padding="3dp"
                                    android:background="@drawable/border" />

                            </android.support.v7.widget.CardView>

                            <ProgressBar
                                android:id="@+id/progress3"
                                android:layout_width="150dp"
                                android:layout_height="30dp"
                                android:layout_gravity="bottom|center_horizontal"
                                android:indeterminate="true" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_marginRight="5dp"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">

                            <android.support.v7.widget.CardView
                                android:id="@+id/img_cv4"
                                android:layout_width="150dp"
                                android:layout_height="150dp"
                                android:layout_marginTop="5dp"
                                android:background="@color/colorCardView"
                                android:visibility="gone">

                                <ImageView
                                    android:id="@+id/iv_photo4"
                                    android:layout_width="150dp"
                                    android:layout_height="150dp"
                                    android:layout_marginRight="5dp"
                                    android:padding="3dp"
                                    android:background="@drawable/border" />

                            </android.support.v7.widget.CardView>

                            <ProgressBar
                                android:id="@+id/progress4"
                                android:layout_width="150dp"
                                android:layout_height="30dp"
                                android:layout_gravity="bottom|center_horizontal"
                                android:indeterminate="true" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_marginRight="5dp"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">

                            <android.support.v7.widget.CardView
                                android:id="@+id/img_cv5"
                                android:layout_width="150dp"
                                android:layout_height="150dp"
                                android:layout_marginTop="5dp"
                                android:background="@color/colorCardView"
                                android:visibility="gone">

                                <ImageView
                                    android:id="@+id/iv_photo5"
                                    android:layout_width="150dp"
                                    android:layout_height="150dp"
                                    android:layout_marginRight="5dp"
                                    android:padding="3dp"
                                    android:background="@drawable/border" />

                            </android.support.v7.widget.CardView>

                        </LinearLayout>

                        <ProgressBar
                            android:id="@+id/progress5"
                            android:layout_width="150dp"
                            android:layout_height="30dp"
                            android:layout_gravity="bottom|center_horizontal"
                            android:indeterminate="true" />
                    </LinearLayout>
                </HorizontalScrollView>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Add upto 5 images, each of max size 4 MB" />

                <android.support.v7.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@color/colorCardView">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="@dimen/cardView_padding">

                        <TextView
                            android:id="@+id/txt_category"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="15dp"
                            android:text="Select Category : "
                            android:textSize="@dimen/textSize" />

                        <Button
                            android:id="@+id/btn_category"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColor="@color/textColorPrimary"
                            android:textStyle="bold"
                            android:background="@drawable/button_background"
                            android:text="Select Category" />

                        <Spinner
                            android:id="@+id/sp_category"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_horizontal"
                            android:layout_marginTop="10dp"
                            android:visibility="gone"
                            android:background="@drawable/spinner_background"
                            android:spinnerMode="dialog" />

                    </LinearLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/cv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="@color/colorCardView">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="@dimen/cardView_padding">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/txt_CharacterCounter"
                            android:layout_marginTop="10dp"
                            android:layout_gravity="end"/>
                        <android.support.design.widget.TextInputLayout
                            android:id="@+id/input_layout_title"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            >

                            <EditText
                                android:id="@+id/edt_title"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Title(maximum 100 characters)*"
                                android:inputType="textNoSuggestions|textVisiblePassword"
                                android:maxLength="100"
                                android:singleLine="true" />
                        </android.support.design.widget.TextInputLayout>


                        <EditText
                            android:id="@+id/edt_desc"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="10dp"
                            android:focusable="false"
                            android:hint="Description(maximum 5000 characters)*"
                            android:singleLine="true" />
                    </LinearLayout>
                </android.support.v7.widget.CardView>


                <CheckBox
                    android:id="@+id/cb_stockimage"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="Add this image you own to stock image"
                    android:visibility="gone" />

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="dummy"
                    android:visibility="invisible" />

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="dummy"
                    android:visibility="invisible" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom|center_horizontal">

    <Button
        android:id="@+id/btn_next_sa2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@drawable/button_corners"
        android:text="Next"
        android:textColor="@color/textColorPrimary"
        android:textSize="@dimen/textSize"
        android:textStyle="bold" />
</RelativeLayout>

Gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "in.net.spectrum.frankstrade"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile 'com.android.support:appcompat-v7:23.1.1'
//compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:design:23.0.1'


compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
//compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v13:23.1.1'

compile 'com.android.support:cardview-v7:21.0.+'
//compile 'com.android.support:recyclerview-v7:23.0.+'

/* compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:23.2.1'
//compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:cardview-v7:21.0.+'*/

//compile files('libs/library.jar')
compile project(':android_process_button_library')
//compile project(':library_smooth_progress_bar')
compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
//compile project(':library_materialEditText')
compile files('libs/universal-image-loader-1.9.0.jar')
//compile 'com.github.darsh2:MultipleImageSelect:v0.0.3'
compile project(':multipleimageselect')



}

显然,我的应用程序中的每个编辑文本在 Android 4.1.1 Jellybean 中都以这种方式显示。我怎么解决这个问题.....? 非常感谢任何帮助。

最佳答案

尝试使用

classpath 'com.android.tools.build:gradle:2.1.0'

在你的 build.gradle(项目:XXXX)

关于android - EditText 在 Lollipop 下方以一种奇怪的方式显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37497082/

相关文章:

android - 从具有内部存储的Android手机上的图库中获取图像

android - 当我将 AspectJ 应用于带有 Androidannotations 的 Android 项目时不起作用

android - 支持不同尺寸的平板电脑的正确方法是什么?

java - 安卓:LinearLayout权重

android - 实现后的 OnBackPressed 将我带回之前的 Activity

android - 工作管理器会唤醒应用程序类吗?它是在应用程序进程还是其他进程上运行?

java - 提高与 ViewFlipper 一起使用的实例化和膨胀 View 的性能

android - 使用不同的来源测试和发布 Android Studio

performance - Android Studio : aapt. exe 创建了太多进程,使 Android Studio 速度很慢

java - 如何转换文本文件以便放置在我的 acharengine 数组中?