2017-12-21 1 views
0

Android 자동 실행 코드가 자동으로 꺼집니다. 번역기 응용 프로그램을 만들려고합니다. 내 레이아웃 디자인에 뭔가 잘못되었다고 생각하지만 무엇을 알아낼 수 없습니까?Android 자동 실행 코드가 자동으로 꺼집니다. 내 레이아웃 디자인에 이상이 있다고 생각하지만 이유를 파악하지 못했습니다.

나는 나의 홈페이지를 두 부분으로 나눴다.

이것은 내 activity_home 레이아웃입니다.

<?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> 

이 내 content_home 레이아웃

<?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> 

당신 잘못이 무엇인지 말해 줄 수 있습니까?

답변

0

나는 제약 조건 레이아웃 때문에 생각합니다. 제약 레이아웃은 버튼, 텍스트 뷰 및 모든 것을 드래그 앤 드롭 할 수있는 Android의 새로운 레이아웃이지만 모든 기기마다 크기가 다르기 때문에 미리보기에는 완벽하지만 휴대 전화에서는 완벽하지는 않습니다. 디스플레이 스크린의 제약 레이아웃이 다른 안드로이드 폰에서 다르게 작동하고 레이아웃 파일에서 경고 또는 오류가 발생할 수 있습니다 .LinearLayout 또는 RelativeLayout을 사용하려고 시도하면 오류가 발생하지 않습니다.

관련 문제