2017-12-21 8 views
0

Android Studio-Code auf Telefon automatisch ausschalten. Ich versuche eine Übersetzeranwendung zu erstellen. Ich denke, es ist etwas falsch in meinem Layout-Design, aber ich kann nicht herausfinden, was.android Studio Running-Code auf Telefon Auto schaltet aus.Ich denke, es ist etwas falsch in meinem Layout-Design, aber ich kann nicht herausfinden, warum

Ich habe meine Homepage in zwei Teile geteilt.

Dies ist meine activity_home Layout.

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.constraint.ConstraintLayout 
    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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:layout_editor_absoluteY="81dp" 
    tools:layout_editor_absoluteX="0dp" 
    android:background="@drawable/bwall1" 
    android:fitsSystemWindows="true" 
    tools:context="nf.co.hoptec.ocr.Home"> 




    <ImageButton 
     android:id="@+id/fab" 
     android:layout_width="100dp" 
     android:layout_height="0dp" 
     android:adjustViewBounds="true" 
     android:background="@drawable/roundcorner" 
     android:cropToPadding="false" 
     android:scaleType="fitCenter" 
     app:layout_constraintHorizontal_bias="0.19" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:srcCompat="@drawable/cameraicon" 
     tools:layout_constraintTop_creator="1" 
     tools:layout_constraintBottom_creator="1" 
     app:layout_constraintBottom_toBottomOf="@+id/fab2" 
     app:layout_constraintTop_toTopOf="@+id/fab2" tools:targetApi="lollipop"/> 

    <ImageButton 
     android:id="@+id/fab2" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:adjustViewBounds="true" 
     android:background="@drawable/roundcorner" 

     android:padding="10dp" 
     android:scaleType="fitCenter" 
     android:src="@drawable/imageicon" 
     tools:layout_constraintRight_creator="1" 
     tools:layout_constraintBottom_creator="1" 
     app:layout_constraintBottom_toBottomOf="parent" 
     android:layout_marginEnd="72dp" 
     app:layout_constraintRight_toRightOf="parent" 
     android:layout_marginBottom="47dp" tools:targetApi="lollipop"/> 

    <include 
     layout="@layout/content_home" 
     android:layout_width="0dp" 
     android:layout_height="400dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintVertical_bias="0.0" 
     tools:layout_constraintBottom_creator="1" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintRight_creator="1" 
     tools:layout_constraintTop_creator="1" /> 


</android.support.constraint.ConstraintLayout> 

Das ist mein content_home Layout

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.NestedScrollView 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:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="0dp" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:context="nf.co.hoptec.ocr.Home" 
     tools:showIn="@layout/activity_home"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="20dp" 
     android:orientation="vertical" 
     android:visibility="visible"> 


    <LinearLayout 
     android:background="@drawable/border" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     android:layout_marginTop="10dp" 
     android:orientation="vertical" 
     android:visibility="visible" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="15dp" 
      android:orientation="horizontal" 
      android:weightSum="1"> 

      <Button 
       android:id="@+id/source" 
       android:layout_width="135dp" 
       android:layout_height="15dp" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:layout_margin="1dp" 
       android:background="#F7F9FC" 
       android:text=":: Source Language ::" 
       android:textColor="#000000" 
       android:textSize="12sp" /> 

      <ImageButton 
       android:id="@+id/proceedbutt" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:background="#00ffffff" 
       android:adjustViewBounds="true" 
       android:cropToPadding="false" 
       android:scaleType="centerCrop" 
       app:srcCompat="@drawable/proceed" 
       android:layout_alignParentEnd="true" /> 

      <ImageButton 
       android:id="@+id/speakerbutt" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:background="#00ffffff" 
       android:adjustViewBounds="true" 
       android:cropToPadding="false" 
       android:scaleType="centerCrop" 
       app:srcCompat="@drawable/speaker" 
       android:layout_marginRight="5dp" 
       android:layout_toLeftOf="@+id/proceedbutt"/> 

      <ImageButton 
       android:id="@+id/copy" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:background="#00ffffff" 
       android:adjustViewBounds="true" 
       android:cropToPadding="false" 
       android:scaleType="centerCrop" 
       app:srcCompat="@drawable/copy" 
       android:layout_marginRight="5dp" 
       android:layout_toLeftOf="@+id/speakerbutt" /> 

     </RelativeLayout> 


     <EditText 
      android:id="@+id/ocrtext" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="30.0dp" 
      android:layout_marginRight="30.0dp" 
      android:layout_marginTop="15dp" 
      android:ems="10" 
      android:inputType="textMultiLine" 
      android:selectAllOnFocus="true" 
      android:singleLine="true" 
      android:text="Type here to translate" 
      android:textSize="12sp" 
      android:layout_marginBottom="15dp"/> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:visibility="visible" 
     android:paddingTop="10dp"> 

     <ImageView 
      android:background="@color/white" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="15dp" 
      android:id="@+id/ocrimg" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/border" 
     android:orientation="vertical" 
     android:visibility="visible"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="15dp" 
      android:orientation="horizontal" 
      android:weightSum="1"> 

      <Button 
       android:id="@+id/target" 
       android:layout_width="135dp" 
       android:layout_height="15dp" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:layout_margin="1dp" 
       android:background="#F7F9FC" 
       android:text=":: Result Language ::" 
       android:textColor="#000000" 
       android:textSize="12sp" /> 

      <ImageButton 
       android:id="@+id/nth" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:layout_alignParentEnd="true" 
       android:background="#00ffffff" 
       app:srcCompat="@drawable/xparent" /> 

      <ImageButton 
       android:id="@+id/speakerbutt1" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:layout_marginRight="5dp" 
       android:layout_toLeftOf="@+id/nth" 
       android:adjustViewBounds="true" 
       android:background="#00ffffff" 
       android:cropToPadding="false" 
       android:scaleType="centerCrop" 
       app:srcCompat="@drawable/speaker" /> 

      <ImageButton 
       android:id="@+id/copyt" 
       android:layout_width="20dip" 
       android:layout_height="20dip" 
       android:layout_marginRight="5dp" 
       android:layout_toLeftOf="@+id/speakerbutt1" 
       android:adjustViewBounds="true" 
       android:background="#00ffffff" 
       android:cropToPadding="false" 
       android:scaleType="centerCrop" 
       app:srcCompat="@drawable/copy" /> 


     </RelativeLayout> 

     <TextView 
      android:id="@+id/ocrtextt" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dp" 
      android:layout_marginLeft="30.0dp" 
      android:layout_marginRight="30.0dp" 
      android:layout_marginTop="15dp" 
      android:background="?attr/editTextBackground" 
      android:ems="10" 
      android:inputType="textMultiLine" 
      android:text="" 
      android:textSize="10sp" /> 

    </LinearLayout> 



</LinearLayout> 

</android.support.v4.widget.NestedScrollView> 

Können Sie mir sagen, was falsch ist?

Antwort

0

Ich denke, es ist wegen der Constraint-Layout.Constraint-Layout ist ein neues Layout von Android, in dem Sie nur Tasten und Textansicht Drag and Drop, aber es sieht in der Vorschau perfekt aussehen, aber nicht in Ihrem Telefon, weil jedes Gerät unterschiedliche Größe haben der Bildschirm so Constraint-Layout funktioniert anders in verschiedenen Android-Handys und Sie können auch eine Warnung oder Fehler in diesem Layout-Datei erhalten.So versuchen, LinearLayout oder RelativeLayout zu verwenden und dann Fehler nicht kommen.

Verwandte Themen