2016-09-18 79 views
1

当应用程序启动时布局很好。但是当视频正在播放时。按钮的布局正在向上移动。 如何解决这个问题? 当应用程序启动? enter image description hereLinearLayout位置正在向上移动,当视频在Videoview中播放时

当视频播放按钮向上enter image description here

移动下面我已经把我一直工作在layoutfile.xml。

<?xml version="1.0" encoding="utf-8"?> 
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="fill_parent" 
 
    android:layout_height="fill_parent" 
 
    android:weightSum="1" 
 
    android:baselineAligned="false" 
 
    android:orientation="horizontal"> 
 
    <LinearLayout 
 
     android:layout_width="0dp" 
 
     android:layout_height="match_parent" 
 

 
     android:layout_weight="0.3" 
 
     android:background="@android:color/background_dark"> 
 

 

 
     <ListView 
 
      android:id="@+id/VideoList" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="match_parent" 
 
      android:background="@android:color/darker_gray" 
 
      android:foreground="@android:color/background_light" /> 
 
    </LinearLayout> 
 

 
    <LinearLayout 
 
     android:layout_width="0dp" 
 
     android:layout_height="wrap_content" 
 
     android:orientation="vertical" 
 
     android:weightSum="1" 
 
     android:layout_weight="0.7"> 
 
     <FrameLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="0.9" 
 
      android:layout_gravity="center_vertical"> 
 

 
      <VideoView 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent" 
 
       android:id="@+id/videoView" 
 
       android:layout_gravity="center" /> 
 

 
     </FrameLayout> 
 
     <Button 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="0.1" 
 
      android:text="New Button" 
 
      android:id="@+id/button"/> 
 

 

 
    </LinearLayout> 
 

 

 
</LinearLayout>

回答

0

你应该做的LinearLayout(包含的FrameLayout和Button)高度match_parent

+0

没有改善同样的问题。 – user41459

0

无需重量总和,才使layout_weights整数像1和9,而不是0.1和0.9

此外,fill_parent已弃用,请改为使用match_parent。

你有一个LinearLayout与单个孩子。不需要,只需将ListView与layout_params相同即可。

最后,右边的垂直LinearLayout应该具有match_parent的高度。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:baselineAligned="false" 
    android:orientation="horizontal"> 

    <ListView 
     android:id="@+id/VideoList" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="3" 
     android:background="@android:color/darker_gray" 
     android:foreground="@android:color/background_light" /> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_weight="7"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="9" 
      android:layout_gravity="center_vertical"> 

      <VideoView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/videoView" 
       android:layout_gravity="center" /> 

     </FrameLayout> 
     <Button 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="New Button" 
      android:id="@+id/button"/> 

    </LinearLayout> 

</LinearLayout> 

编辑:修正了LinearLayout上的布局参数。

+0

也通过使用以下布局代码。我曾经遇到同样的问题。 – user41459

0

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:baselineAligned="false" 
 
    android:orientation="horizontal"> 
 

 
    <ListView 
 
     android:id="@+id/VideoList" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:layout_weight="3" 
 
     android:background="@android:color/darker_gray" 
 
     android:foreground="@android:color/background_light" /> 
 

 
    <LinearLayout 
 
     android:layout_width="0dp" 
 
     android:layout_height="match_parent" 
 
     android:orientation="vertical" 
 
     android:layout_weight="7"> 
 

 
     <FrameLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="9" 
 
      android:layout_gravity="center_vertical"> 
 

 
      <VideoView 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent" 
 
       android:id="@+id/videoView" 
 
       android:layout_gravity="center" /> 
 

 
     </FrameLayout> 
 
     <Button 
 
      android:layout_width="match_parent" 
 
      android:layout_height="0dp" 
 
      android:layout_weight="1" 
 
      android:text="New Button" 
 
      android:id="@+id/button"/> 
 

 
    </LinearLayout> 
 

 
</LinearLayout>

我已经做了列表视图中的 “layout_width” 和 “layout_height” 既要match_parent变化,现在它正在

相关问题