Android Smudged layout

2019-01-01 09:20发布

问题:

I\'ve never seen a thing like this, my layout is just smudged on my device (Infinix Zero X506 running Android 4.4.2) however on an emulator it displays just fine, I can\'t figure out the cause and I haven\'t seen a similar question here or on Google. I am using Android Studio 2.2 Preview 1 Below is an image \"Layout

Below is my layout xml

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"
  android:layout_width=\"match_parent\"
  android:layout_height=\"match_parent\"
  android:layout_margin=\"@dimen/activity_horizontal_margin\">
<LinearLayout
    android:layout_width=\"match_parent\"
    android:layout_height=\"wrap_content\"
    android:orientation=\"vertical\">
    <TextView
        android:text=\"@string/title\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/textView\"
        android:textStyle=\"bold\"/>

    <EditText
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:inputType=\"textCapSentences\"
        android:hint=\"@string/enter_title\"
        android:ems=\"10\"
        android:maxLines=\"2\"
        android:id=\"@+id/edName\" />

    <TextView
        android:text=\"@string/to_do_details\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/textView2\"
        android:textStyle=\"bold\"
        android:layout_marginTop=\"10dp\"/>

    <EditText
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:inputType=\"textMultiLine|textCapSentences\"
        android:ems=\"10\"
        android:hint=\"@string/enter_to_do_details\"
        android:id=\"@+id/edDetails\" />

    <TextView
        android:text=\"@string/select_priority\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/textView3\"
        android:textStyle=\"bold\"
        android:layout_marginTop=\"10dp\"/>

    <Spinner
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/spPriority\"
        />
    <TextView
        android:text=\"@string/set_time\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/textView6\"
        android:textStyle=\"bold\"
        android:layout_marginTop=\"10dp\"/>
    <Button
        android:background=\"@color/colorAccent\"
        android:textStyle=\"bold\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:gravity=\"center\"
        android:id=\"@+id/btDate\"
        />
    <TextView
        android:text=\"@string/set_date\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/textView4\"
        android:textStyle=\"bold\"
        android:layout_marginTop=\"10dp\"/>

    <Button
        android:background=\"@color/colorAccent\"
        android:textStyle=\"bold\"
        android:layout_width=\"match_parent\"
        android:layout_height=\"wrap_content\"
        android:gravity=\"center\"
        android:id=\"@+id/btTime\"
        />

    <Button
        android:layout_marginTop=\"@dimen/activity_vertical_margin\"
        android:layout_width=\"wrap_content\"
        android:layout_height=\"wrap_content\"
        android:id=\"@+id/button\"
        android:text=\"@string/save\"
        android:gravity=\"center\"
        android:layout_gravity=\"center\"/>
 </LinearLayout>
</ScrollView>

The entries in the spinner are feed from a custom adapter if that helps

回答1:

This is confirmed fixed with Android Studio 2.2 Preview 4

So you no longer need to revert to plugin version 2.1.0 as the original answer explained.

Original Answer:

This is a problem with the alpha version of the gradle plugin. You can continue using Android Studio 2.2 if you revert the plugin version to 2.1.0, like so:

buildscript {

    ...

    dependencies {
        // other entries here
        classpath \'com.android.tools.build:gradle:2.1.0\'
    }

    ...

}

In your root projects build.gradle

Please vote for the issue to be fixed on the official bug tracker entry here