Rak*_*ela 5 android android-layout navigation-drawer drawerlayout swiperefreshlayout
这两种布局都可以在appcompat支持库7中找到.
我没有得到适当的结果.
我将DrawerLayout作为根布局,然后在其中包含一个错误文本视图.然后是SwipeRefreshLayout
当根布局为FrameLayout时,该textview是可见的.但自从我将根布局更改为DrawerLayout后,可能会出现错误textview从未显示!
我正确使用它吗?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context="com.timesbuzz.news.MainActivity"
android:id="@+id/drawer_layout">
<TextView
android:id="@+id/errorView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/error_view_text"
android:textSize="30sp" />
<ProgressBar
android:id="@+id/loadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- android.support.v4.view.ViewPager -->
<fr.castorflex.android.verticalviewpager.VerticalViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/navdrawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false">
</ListView>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
技巧:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context="com.timesbuzz.news.MainActivity"
android:id="@+id/drawer_layout">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!-- you need to re-layout your widgets as you want -->
<TextView
android:id="@+id/errorView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/error_view_text"
android:textSize="30sp" />
<ProgressBar
android:id="@+id/loadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- android.support.v4.view.ViewPager -->
<fr.castorflex.android.verticalviewpager.VerticalViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/navdrawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false">
</ListView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1921 次 |
| 最近记录: |