2016-04-07 15 views
0

でImageViewの伸縮されていますnestedScrollView iが..巣にnestedscrollview内側のLinearLayout内部ImageViewのをしようとしている。しかしnestedscrollviewはImageViewのを伸ばしていると私は、エラーを見つけることができないようアンドロイド

レイアウトファイル:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:fitsSystemWindows="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

      <LinearLayout 
       android:id="@+id/llImageview" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_marginTop="?attr/actionBarSize" 
       android:layout_weight="0.6" 
       android:orientation="horizontal"> 

       <ImageView 
        android:id="@+id/ivNewProductBarcode" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:adjustViewBounds="true" 
        android:background="@drawable/no_barcode_image" 
        android:scaleType="centerCrop"/> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.45" 
       android:background="@color/cardview_dark_background" 
       android:baselineAligned="true" 
       android:orientation="vertical"> 


       <LinearLayout 
        android:id="@+id/llRest" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 

        <ImageView 
         android:id="@+id/ivDateIconView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_toStartOf="@+id/etProductName" 
         android:background="@color/card_background" 
         android:contentDescription="ImageView for icon: Date" /> 

        <EditText 
         android:id="@+id/etProductName" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="40dp" 
         android:layout_marginRight="30dp" 
         android:layout_marginTop="30dp" 
         android:hint="Name" /> 

        <EditText 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="40dp" 
         android:layout_marginRight="30dp" 
         android:layout_marginTop="80dp" 
         android:hint="Type" /> 
       </LinearLayout> 

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

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="16dp" 
     android:clickable="true" 
     android:src="@drawable/ic_camera_alt_24dp" 
     app:layout_anchor="@id/llImageview" 
     app:layout_anchorGravity="bottom|right|end" /> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/my_toolbar_new_product" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:elevation="4dp" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
     android:title="@string/newproducttitle" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 


</android.support.design.widget.CoordinatorLayout> 

そして、それは電話でどのように見えるかの画像: Image Stretched Image Stretched and rest of gui

答えて

0

デザインLIBSは23.3.0になりましたように、私は、全体のレイアウトファイルを再コーディング終わった、と私のGradleモジュールファイルを更新それは何とか問題を解決しました。同じ問題に遭遇し、他人のために、ここに私のレイアウトのコードであり、Gradleのスクリプト:

レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/coAddNewProductContainer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

      <LinearLayout 
       android:id="@+id/llImageView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.6"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:adjustViewBounds="true" 
        android:src="@drawable/no_barcode_image" /> 
      </LinearLayout> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="0.4" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/tvDatePick" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="50dp" 
        android:layout_marginRight="20dp" 
        android:layout_marginTop="60dp" 
        android:text="Date to pick" /> 

       <EditText 
        android:id="@+id/etName" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_below="@id/tvDatePick" 
        android:layout_marginLeft="50dp" 
        android:layout_marginRight="20dp" 
        android:layout_marginTop="30dp" 
        android:hint="@string/testingString" /> 

       <EditText 
        android:id="@+id/etType" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_below="@id/etName" 
        android:layout_marginLeft="50dp" 
        android:layout_marginRight="20dp" 
        android:layout_marginTop="30dp" 
        android:hint="@string/app_name" /> 

       <ImageView 
        android:layout_width="12dp" 
        android:layout_height="12dp" 
        android:layout_toLeftOf="@+id/etName" /> 

      </RelativeLayout> 
     </LinearLayout> 

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

    <android.support.design.widget.FloatingActionButton 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="16dp" 
     android:clickable="true" 
     android:src="@drawable/ic_camera_alt_24dp" 
     app:layout_anchor="@id/llImageView" 
     app:layout_anchorGravity="bottom|right|end" /> 

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

     <android.support.v7.widget.Toolbar 
      android:id="@+id/my_toolbar_new_product" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlwaysCollapsed" /> 
    </android.support.design.widget.AppBarLayout> 
</android.support.design.widget.CoordinatorLayout> 

のGradle:

... 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 

    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.android.support:design:23.3.0' 
    compile 'com.android.support:cardview-v7:23.3.0' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.google.android.gms:play-services:8.4.0' 
    compile 'com.google.android.gms:play-services-ads:8.4.0' 
    compile 'com.google.android.gms:play-services-identity:8.4.0' 
    compile 'com.google.android.gms:play-services-gcm:8.4.0' 
} 
... 
0

この

をお試しくださいFIXED

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

     <LinearLayout 
      android:id="@+id/llImageview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="?attr/actionBarSize" 
      android:layout_weight="0.6" 
      android:orientation="horizontal"> 

      <ImageView 
       android:id="@+id/ivNewProductBarcode" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:adjustViewBounds="true" 
       android:background="@mipmap/ic_launcher" 
       android:scaleType="fitXY"/> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.45" 
      android:background="@color/colorAccent" 
      android:baselineAligned="true" 
      android:orientation="vertical"> 


      <LinearLayout 
       android:id="@+id/llRest" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <ImageView 
        android:id="@+id/ivDateIconView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toStartOf="@+id/etProductName" 
        android:background="@color/colorAccent" 
        android:contentDescription="ImageView for icon: Date" /> 

       <EditText 
        android:id="@+id/etProductName" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="40dp" 
        android:layout_marginRight="30dp" 
        android:layout_marginTop="30dp" 
        android:hint="Name" /> 

       <EditText 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="40dp" 
        android:layout_marginRight="30dp" 
        android:layout_marginTop="80dp" 
        android:hint="Type" /> 
      </LinearLayout> 

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

<android.support.design.widget.FloatingActionButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="16dp" 
    android:clickable="true" 
    android:src="@mipmap/ic_launcher" 
    app:layout_anchor="@id/llImageview" 
    app:layout_anchorGravity="bottom|right|end" /> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/my_toolbar_new_product" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    android:elevation="4dp" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
    android:title="product" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

+0

はちょうど私の質問を更新しましたが、それは残念ながらありませんでした私の問題を解決する..:/しかし、お試しいただきありがとうございます – Lasse

+0

私の答えを更新@Lasseを試してください – HourGlass

+0

まだ動作していません..それは問題であるlayout_weightようです.. – Lasse

関連する問題