2014-01-13 14 views
1

В Fragment, когда код в if else обнаруживает ошибку функции, он установит setVisibilityFramelayout на VISIBLE, как на следующий псевдокод.Как настроить два RelativeLayout в Framelayout?

Мне нужен вид сверху, поэтому я использую framelayout.

public static FrameLayout reconnect_layout; 
reconnect_layout = (FrameLayout) view.findViewById(R.id.reconnect_layout); 

if(error) { 
reconnect_layout.setVisibility(View.VISIBLE); 
}else(
    //do nothing 
} 

Он покажет framelayout когда error верно. Но layout в framelayout смущает, как на следующем рисунке.

https://drive.google.com/file/d/0B1K3BXnzMP5CLWQyME5ZdEZ0T0E/edit?usp=sharing https://drive.google.com/file/d/0B1K3BXnzMP5CbkQxRVByMzF5anc/edit?usp=sharing

Когда телефон вертикально, а view выглядеть немного ненормальным. Только положение двух последних виджета (Imgbtn_reconnect и reconnect_text) является ненормальным.

И телефон горизонтальный, view - беспорядок.

Я хочу second RelativeLayout ниже second RelativeLayout. Но он не может использовать layout_below

Код этого 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:baselineAligned="false" 
    android:orientation="vertical" > 



    <FrameLayout 
     android:id="@+id/player_frame" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <FrameLayout 
      android:id="@+id/player_surface_frame" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_gravity="center" > 

      <SurfaceView 
       android:id="@+id/player_surface" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_gravity="center" /> 

     </FrameLayout> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/reconnect_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:visibility="gone" 
     android:layout_below="@+id/top_buttonlayout1" 
     android:layout_above="@+id/bottom_buttonlayout1" 
     android:background="#000000">   

     <LinearLayout 
     android:id="@+id/layout_imgbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:orientation="horizontal" > 

      <ImageView 
       android:id="@+id/phone" 
       android:layout_width="96dp" 
       android:layout_height="96dp" 
       android:src="@drawable/phone"/> 

      <ImageView 
       android:id="@+id/connect" 
       android:layout_width="96dp" 
       android:layout_height="96dp" 
       android:src="@drawable/break1"/> 

      <ImageView 
       android:id="@+id/break_image" 
       android:layout_width="96dp" 
       android:layout_height="96dp" 
       android:src="@drawable/camera_break" 
       /> 

     </LinearLayout> 


     <LinearLayout 
     android:id="@+id/Reconnect_text_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center_horizontal" 
     android:orientation="vertical" > 

      <TextView 
       android:id="@+id/break_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#FFFFFF" 
       android:gravity="center" 
       android:text="@string/connection_break_message"/> 

      <ImageButton 
       android:id="@+id/Imgbtn_reconnect" 
       android:layout_width="72dp" 
       android:layout_height="72dp" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/reconnect" /> 

      <TextView 
       android:id="@+id/reconnect_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/Reconnect" 
       android:layout_gravity="center_horizontal" 
       android:textColor="#FFFFFF" /> 


     </LinearLayout> 
    </FrameLayout> 


    <LinearLayout 
     android:id="@+id/top_buttonlayout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="10dp" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/top_buttonlayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#444444" > 

      <ImageView 
       android:id="@+id/imageBackground" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@+id/SettingButton" 
       android:layout_toLeftOf="@+id/SettingButton" 
       android:scaleType="fitStart" 
       android:src="@drawable/smart_cam" 
       /> 


      <ImageButton 
       android:id="@+id/SettingButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toLeftOf="@+id/FileSavebutton" 
       android:scaleType="fitXY" 
       android:layout_marginRight="10dp" 
       android:layout_marginLeft="10dp" 
       android:background="@drawable/parmeter_setting" /> 



      <ImageButton 
       android:id="@+id/FileSavebutton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:scaleType="fitXY" 
       android:background="@drawable/save_in_camera" /> 

     </RelativeLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 
       <TextView 
       android:id="@+id/TimeStampLabel" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="10dip" 
       android:text="" 
       android:textColor="#ffff00" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

       <TextView 
       android:id="@+id/RecordState" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="10dip" 
       android:text="" 
       android:textColor="#ff0000" /> 

       <TextView 
       android:id="@+id/RecordTime" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right" 
       android:layout_margin="10dip" 
       android:text="" 
       android:textColor="#ff0000" /> 

     </LinearLayout> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/bottom_buttonlayout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical" 
     android:background="#454749" 
     > 

     <RelativeLayout 
      android:id="@+id/bottom_buttonlayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 


      <ImageButton 
       android:id="@+id/FileButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:scaleType="fitXY" 
       android:background="#454749" 
       android:layout_centerInParent="true" 
       android:src="@drawable/file_viewer"/> 



      <ImageButton 
       android:id="@+id/photo_record_mode" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerInParent="true" 
       android:scaleType="fitXY" 
       android:background="#454749" 
       android:src="@drawable/recordmode"/> 

      <ImageButton 
       android:id="@+id/recordButton" 
       android:layout_width="80dp" 
       android:layout_height="80dp" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       android:background="#454749" 
       android:scaleType="fitXY" 
       android:src="@drawable/record" /> 

     </RelativeLayout> 
    </LinearLayout> 

</RelativeLayout> 

Как изменить виджеты в Framlayout в норме? Я хочу second RelativeLayout ниже second RelativeLayout. Но он не может использовать layout_below

ответ

0

Вы уверены, что вам нужен FrameLayout? FrameLayout не размещает один вид над другим на экране, он рисует одно представление и затем рисует другое представление в тех же координатах. Например, он может затемнить изображение, сначала рисуя исходное изображение, а затем рисуя полупрозрачное представление, фон которого - # 80000000.

Для вашей цели вы можете использовать, скажем, LinearLayout, и программно установить видимость одного вида GONE, а другого - VISIBLE.

+0

Но у меня есть другой Framelayout, поэтому я хочу использовать framelayout для наложения всего макета. Я пытаюсь изменить framelayout на LinearLayout. Он выйдет из строя из-за другого framelayout. – Martin

+0

Я размещаю весь файл xml – Martin

+0

'android: layout_below =" @ + id/top_buttonlayout1 "' - + не нужен, это значит «создать новый» – 18446744073709551615

Смежные вопросы