2016-02-28 152 views
-1

我有一个相对布局,其中有一个照片库和一个媒体播放器。我的问题是我想让媒体播放器控制(暂停/播放/前进/后退)4个按钮位于屏幕的底部,同时保持其中心水平对齐。我所做的是里面嵌套线性布局的相对布局。如何将线性布局放置在屏幕底部?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
android:id="@+id/main_audio_view" 
android:layout_height="match_parent" 
android:background="@drawable/backgroundimg" 
tools:context="com.my.project.LaunchGalleryview"> 

    <LinearLayout android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:orientation="horizontal" 
     android:layout_centerInParent="true" 
     android:gravity="bottom" 
     > 
    </LinearLayout> 

</RelativeLayout> 

线性布局内的cutton全部居中,但整个线性布局位于我的屏幕中心。我希望它在屏幕的底部。我已经尝试过andoird:gravity =“bottom”它仍然位于屏幕的中心位置,我如何强制它位于底部?在线性布局

+0

为什么如果你想在底部使用'android:layout_centerInParent'?你为什么不使用'alignParentBottom'? –

+0

很抱歉,英文不是我的第一语言,这就是为什么我难以理解文档。我想保持水平中心对齐,这就是为什么我认为layout_centerInParent将使用重力完成这项工作并将其拉下到屏幕的底部:“bottom”。这是我的问题的整个点(误解文件) – TwoThumbSticks

+0

我不明白为什么人们喜欢downvote新手初学者水平的问题这个人获得什么?请记住,你曾经是新手,犯了愚蠢的错误,也误解了apis。也不是每个人都有第一语言的英语。上次我检查这是一个社区互相帮助,我不知道新手不欢迎在这里问。 – TwoThumbSticks

回答

0

而不是

android:layout_centerInParent="true" 

使用

android:layout_alignParentBottom="true" <!-- Bottom of the RelativeLayout --> 
android:gravity="center" <!-- centers all child views within the LinearLayout --> 
0

只需添加android:layout_alignParentBottom="true"到的LinearLayout

0

试试这个

android:layout_alignParentBottom="true"