我正在尝试使用SwipeRefreshLayout和工具栏但是每次我使用Progress Circle都会出现在工具栏上,这在设计方面非常糟糕.我尝试将SwipeRefreshLayout放在工具栏下但不起作用,进度圆仍然出现在它上面(状态栏上方).我想像Gmail应用程序一样同时使用工具栏和布局.我正在使用AppCompat库.
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/bluetooth_toolbar"
android:id="@+id/bluetooth_toolbar"/>
<TextView
android:id="@+id/swipeTo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swipe down to refresh"
android:textSize="20sp"
android:layout_below="@+id/bluetooth_toolbar"
android:layout_centerHorizontal="true" />
<ListView
android:id="@+id/newDevices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/swipeTo"
android:layout_marginTop="50dp" />
<ListView
android:id="@+id/pairedDevices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/newDevices"
android:layout_marginTop="50dp" />
</RelativeLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
和
public class BluetoothActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
private static final int REQUEST_ENABLE_BT = 0;
private BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
private SwipeRefreshLayout mSwipeRefreshLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); …
Run Code Online (Sandbox Code Playgroud) android toolbar swiperefreshlayout android-toolbar appcompatactivity