Android ListView与AppBarLayout的冲突

Android ListView与AppBarLayout的冲突,android,listview,Android,Listview,我的ListView问题 ListView与AppBarLayout的冲突 我想在AppBarLayout下 中间页的进度条 如何将应用程序栏标题和后退按钮移到右侧 activity_category.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schem

我的ListView问题

ListView与AppBarLayout的冲突

我想在AppBarLayout下

中间页的进度条

如何将应用程序栏标题和后退按钮移到右侧

activity_category.xml

<?xml version="1.0" encoding="utf-8"?>
<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_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.sokhanak.CategoryActivity">

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

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="?attr/colorPrimary" />

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

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v4.widget.ContentLoadingProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical"
        android:visibility="visible" />

    <ListView
        android:id="@+id/listView"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</FrameLayout>
</LinearLayout>

CategoryActivity.java

package com.example;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.ContentLoadingProgressBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.adapter.QuoteArrayAdapter;
import com.example.model.QuoteDataModel;
import com.example.parser.JSONParser;
import com.example.utils.Keys;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

public class CategoryActivity extends AppCompatActivity {

    private Toolbar toolbar;
    private ListView listView;
    private ArrayList<QuoteDataModel> list;
    private QuoteArrayAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_category);

        Intent i = getIntent();
        final String categoryId = i.getStringExtra("categoryId");
        String categoryName = i.getStringExtra("categoryName");

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(categoryName);

        /**
         * Array List for Binding Data from JSON to this List
         */
        list = new ArrayList<>();

        adapter = new QuoteArrayAdapter(this, list);

        /**
         * Getting List and Setting List Adapter
         */
        listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Snackbar.make(findViewById(R.id.parentLayout), list.get(position).getProfileName() + " => " + list.get(position).getQuoteLike(), Snackbar.LENGTH_LONG).show();
            }
        });

        /**
         * Check internet connection
         */
        if (!MainActivity.NetworkUtil.isOnline(getApplicationContext())) {
            Toast.makeText(CategoryActivity.this, "اتصال به اینترنت برقرار نیست",
                    Toast.LENGTH_LONG).show();
        }

        new GetDataCategory().execute(categoryId);

        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            public void onScrollStateChanged(AbsListView view, int scrollState) {


            }

            public void onScroll(AbsListView view, int firstVisibleItem,
                                 int visibleItemCount, int totalItemCount) {

                if(firstVisibleItem+visibleItemCount == totalItemCount && totalItemCount!=0)
                {
                    new GetDataCategory().execute(categoryId);
                }
            }
        });

        // screen turn on ever
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    }

/* */
}
package.com.example;
导入android.content.Intent;
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.support.annotation.Nullable;
导入android.support.design.widget.Snackbar;
导入android.support.v4.widget.ContentLoadingProgressBar;
导入android.support.v7.app.AppActivity;
导入android.support.v7.widget.Toolbar;
导入android.util.Log;
导入android.view.view;
导入android.view.WindowManager;
导入android.widget.AbsListView;
导入android.widget.AdapterView;
导入android.widget.ListView;
导入android.widget.Toast;
导入com.example.adapter.QuoteArrayAdapter;
导入com.example.model.QuoteDataModel;
导入com.example.parser.JSONParser;
导入com.example.utils.Keys;
导入org.json.JSONArray;
导入org.json.JSONException;
导入org.json.JSONObject;
导入java.util.ArrayList;
公共类CategoryActivity扩展了AppCompatActivity{
专用工具栏;
私有列表视图列表视图;
私有数组列表;
专用适配器;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_类别);
Intent i=getIntent();
最终字符串categoryId=i.getStringExtra(“categoryId”);
String categoryName=i.getStringExtra(“categoryName”);
toolbar=(toolbar)findviewbyd(R.id.toolbar);
设置支持操作栏(工具栏);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(categoryName);
/**
*用于将数据从JSON绑定到此列表的数组列表
*/
列表=新的ArrayList();
adapter=new QuoterArrayAdapter(此,列表);
/**
*获取列表和设置列表适配器
*/
listView=(listView)findViewById(R.id.listView);
setAdapter(适配器);
setOnItemClickListener(新的AdapterView.OnItemClickListener(){
@凌驾
public void onItemClick(AdapterView父对象、视图、整型位置、长id){
Snackbar.make(findviewbyd(R.id.parentLayout),list.get(position.getProfileName()+“=>”+list.get(position.getQuoteLike(),Snackbar.LENGTH_LONG).show();
}
});
/**
*检查互联网连接
*/
如果(!MainActivity.NetworkUtil.isOnline(getApplicationContext())){
Toast.makeText(CategoryActivity.this,“Toast.makeText”(CategoryActivity.this),“Toast.makeText(CategoryActivity.this)”,
Toast.LENGTH_LONG).show();
}
新建GetDataCategory().execute(categoryId);
setOnScrollListener(新的AbsListView.OnScrollListener(){
公共无效onScrollStateChanged(AbsListView视图,int scrollState){
}
public void onScroll(AbsListView视图,int firstVisibleItem,
int visibleItemCount,int totalItemCount){
如果(firstVisibleItem+visibleItemCount==totalItemCount&&totalItemCount!=0)
{
新建GetDataCategory().execute(categoryId);
}
}
});
//屏幕一直打开
getWindow().addFlags(WindowManager.LayoutParams.FLAG\u保持屏幕打开);
}
/* */
}

将相对布局更改为垂直方向的线性布局

/**在listview中进行更改**/
 /**Make a change in your listview**/

   ListView Interference with AppBarLayout:


  <ListView 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:id="@+id/listView"
    android:layout_below="@+id/toolbar"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" />


    App bar Title and back button to Right: 

    Just add below line inside application tag in AndroidManifestFile

    android:supportsRtl="true"
ListView与AppBarLayout的冲突: 应用程序栏标题和右侧的后退按钮: 只需在AndroidManifestFile中的应用程序标记内添加下一行 android:supportsRtl=“true”
要将列表放在应用程序栏下方,您需要使用下方的应用程序栏更新listview布局。
这是更新后的代码。

如果您使用relativelayout,您必须将小部件相对放置。不工作android:layout_down=“@+id/toolbar”| android:supportsRtl=“true”无效请编辑布局代码,我的第一个项目是AndroidCheck我编辑了您的布局代码。谢谢。仅顶部列表视图上的progressbar,我想要中间页
    For putting list below app bar you need to update listview layout with below app bar.
    Here is the updated code.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/activity_category"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.sokhanak.CategoryActivity"
        >
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:background="?attr/colorPrimary"
                />

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

        <android.support.v4.widget.ContentLoadingProgressBar
            android:id="@+id/progress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="visible" />

        <ListView app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/listView"
            android:layout_below="@+id/appBarLayout"
            android:layout_width="fill_parent"
            android:layout_height="match_parent" />

    </RelativeLayout>