2013-12-09 49 views
1

我想全屏加载图像,并把两个按钮栏(一个在顶部,一个在底部)。但是,当我测试应用程序时,顶栏显示完整图像,而底栏显示正常。视图变得隐藏在Android活动中的其他视图

enter image description here

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:id="@+id/relshare" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:background="#60000000" > 

    <Button 
     android:id="@+id/btnBack" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/setaswallpaper" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/back_button" 
     android:gravity="right" /> 

    <Button 
     android:id="@+id/setaswallpaper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/set_wallpaper" 
     android:gravity="right" 
     android:textSize="25sp" /> 

    <Button 
     android:id="@+id/bshare" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/setaswallpaper" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/share" 
     android:gravity="right" /> 
</RelativeLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fadingEdgeLength="10dp" 
    android:filterTouchesWhenObscured="true" 
    android:focusableInTouchMode="false" 
    android:scrollbarDefaultDelayBeforeFade="100000" /> 

<ProgressBar 
    android:id="@+id/pb" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" /> 

<RelativeLayout 
    android:id="@+id/relshare2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="#60000000" > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/bfavorite" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:background="@drawable/favorite1" 
      android:gravity="left" 
      android:padding="10dp" 
      android:textSize="25sp" /> 

     <TextView 
      android:layout_width="40dp" 
      android:layout_height="40dp" /> 

     <Button 
      android:id="@+id/download" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:background="@drawable/download" 
      android:gravity="right" 
      android:padding="10dp" 
      android:textSize="25sp" /> 
    </LinearLayout> 

    <Button 
     android:id="@+id/info" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_alignParentRight="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/info" /> 

    <Button 
     android:id="@+id/reportissue" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="50dp" 
     android:layout_height="40dp" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/report_issue" 
     android:text="" /> 
</RelativeLayout> 
</RelativeLayout> 

请帮我解决这个错误

+0

尝试使用'FrameLayout'作为根布局 – Apoorv

回答

1

在XML试试这个?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fadingEdgeLength="10dp" 
    android:filterTouchesWhenObscured="true" 
    android:focusableInTouchMode="false" 
    android:scrollbarDefaultDelayBeforeFade="100000" /> 

<ProgressBar 
    android:id="@+id/pb" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" /> 

<RelativeLayout 
    android:id="@+id/relshare" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:background="#60000000" > 

    <Button 
     android:id="@+id/btnBack" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/setaswallpaper" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/back_button" 
     android:gravity="right" /> 

    <Button 
     android:id="@+id/setaswallpaper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/set_wallpaper" 
     android:gravity="right" 
     android:textSize="25sp" /> 

    <Button 
     android:id="@+id/bshare" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/setaswallpaper" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/share" 
     android:gravity="right" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/relshare2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="#60000000" > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/bfavorite" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:background="@drawable/favorite1" 
      android:gravity="left" 
      android:padding="10dp" 
      android:textSize="25sp" /> 

     <TextView 
      android:layout_width="40dp" 
      android:layout_height="40dp" /> 

     <Button 
      android:id="@+id/download" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:background="@drawable/download" 
      android:gravity="right" 
      android:padding="10dp" 
      android:textSize="25sp" /> 
    </LinearLayout> 

    <Button 
     android:id="@+id/info" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:layout_alignParentRight="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/info" /> 

    <Button 
     android:id="@+id/reportissue" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="50dp" 
     android:layout_height="40dp" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/report_issue" 
     android:text="" /> 
</RelativeLayout> 
</RelativeLayout> 

重新排序XML总是有助于解决此问题。

+0

非常感谢。它像一个魅力。你能解释一下这背后的逻辑吗? –

+0

原因是因为你的viewpager出现在你的状态栏之后。在Android视图刷新中,它按照XML的顺序进行。进一步的解释是在这里:http://developer.android.com/reference/android/view/View.html#Drawing :)我很高兴它的帮助!如果是这样,请将其标记为正确:) – SalGad

+0

我已经尝试接受这篇文章作为答案,但是SO告诉我等5分钟才能接受答案。 –

0

将以下属性添加到您的ViewPager。

android:layout_below="@id/relshare" 
android:layout_above="@id/relshare2" 

当然,你必须移动上述ViewPager relshare2声明。

+0

感谢您的建议,但实际上我希望图像覆盖整个屏幕 –

+1

好的,然后只在xml文件中的ViewPager下移动relshare声明。 –