-1

これは、ナビゲーションバーとスクロールビューを使用している私のレイアウトです。スクロールビューのナビゲーションバーandroid

<android.support.design.widget.CoordinatorLayout 
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:fitsSystemWindows="true" 
tools:context=".AccountActivity"> 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <!-- your content layout --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     > 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      app:elevation="0dp"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:minHeight="?attr/actionBarSize" 
       app:elevation="0dp" /> 

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

     <!--content of account activity--> 

     <ScrollView 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      > 

      <RelativeLayout 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:id="@+id/activity_setup" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       tools:context=".AccountActivity"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:background="@drawable/listgrad" 
        android:id="@+id/imageView" 
        android:layout_height="100dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:inputType="textPersonName" 
        android:text="Name" 
        android:layout_below="@+id/profilepic" 
        android:id="@+id/accountnamefield" 
        android:textSize="18sp" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" /> 


       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Recently Match" 
        android:id="@+id/recentMatchTitle" 
        android:textSize="18sp" 
        android:layout_below="@+id/accountnamefield" 
        android:layout_centerVertical="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" /> 

       <android.support.v7.widget.RecyclerView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/recentMatchProductList" 
        android:layout_below="@+id/recentMatchTitle" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true"> 
       </android.support.v7.widget.RecyclerView> 

       <ImageButton 
        android:layout_width="150dp" 
        android:layout_height="150dp" 
        app:srcCompat="@mipmap/ic_account_circle_white_36dp" 
        android:id="@+id/profilepic" 
        android:background="@drawable/round_button" 
        android:layout_marginTop="21dp" 
        android:layout_alignParentTop="true" 
        android:layout_centerHorizontal="true" /> 

      </RelativeLayout> 

     </ScrollView> 

    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/drawer" /> 

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

私はNAVの引き出し付きスクロールビューを使用しています。ナビゲーション・ドロワーを開いて閉じると、ビューが下の位置にスクロールするのはなぜですか?一番上に移動したり、同じ位置を維持できますか?助けてください。

答えて

0

あなたのレイアウトは問題の束を持っています

アンドロイド:layout_alignParentStart = "true" を - (RTL用または右)同じ左のようなもの アンドロイド:layout_alignParentEnd = "true" を - (右と同じものか悪い習慣と働くことはありません - は

それは開始を宣言し、ScrollView内のリサイクルビューを使用して、同じ時間

に左に間違っている)RTL放置しました。ネストされたスクロールビュー(RecyclerView inside ScrollView is not working)を使用できますが、より良い解決策は、スクロールビュー内に(ヘッダーとフッターとして)必要なものを配置することです。

レイアウトを測定する方法がないと思います。アンドロイドがビューを描画している様子を把握してみてください(https://medium.com/@britt.barak/measure-layout-draw-483c6a4d2fab#.y7nd8gyql)。

P.S.すべての問題を指すよりも、レイアウトにはるかに多くの問題があり、新しいものを書くのは簡単です。

+0

アンドロイドを使用しながら

ここで、私はテストのために使用されるコードをポストする、ScrollViewは同じ位置を維持しました私はXMLを使用してビューをドラッグします。私はそのウェブサイトを探すだろうし、1つの活動で多くの意見を扱うことはまだあまり良くない。ありがとうございました。 – ng2b30

2

あなたScrollView .ITにandroid:scrollbars="vertical"を追加TextView .Then するための第1のandroid:inputType="textPersonName"の部分を削除するには、私のためにうまく働きました。 layout_alignParentStart = "真" とAndroid:layout_alignParentEnd = "true" が自動的に生成されたNavigationDrawer

<android.support.design.widget.CoordinatorLayout 
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:fitsSystemWindows="true" 
tools:context=".MainActivity"> 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <!-- your content layout --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     > 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      app:elevation="0dp"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:minHeight="?attr/actionBarSize" 
       app:elevation="0dp" /> 

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

     <!--content of account activity--> 

     <ScrollView 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:scrollbars="vertical" 
      > 

      <LinearLayout 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:id="@+id/activity_setup" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       tools:context=".MainActivity"> 


       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/bla" 
        android:id="@+id/accountnamefield" 
        android:textSize="18sp" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" 
        /> 


       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Recently Match" 
        android:id="@+id/recentMatchTitle" 
        android:textSize="18sp" 
        android:layout_below="@+id/accountnamefield" 
        android:layout_centerVertical="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" /> 



      </LinearLayout> 

     </ScrollView> 

    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 

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

+0

あなたの答えをありがとう。しかし、私は私の問題を解決することはできません。私はスクロールビューがリサイクルビューの影響を受けるので、底に行くと思います。 – ng2b30

関連する問題