2014-12-04 47 views
0

正如線程名稱所述,我面臨着重疊元素的問題。我需要做一些類似頁腳的東西,它總是處於佈局的底部,並且不會重疊元素。我在下面發佈我的佈局。我認爲問題在於我如何定位評級欄和線性佈局,這應該是在底部。佈局 - 圖像不在底部並重疊

PS不要怪我,因爲我使用相對佈局的方式,滑塊應該有一個父相對佈局和滾動型只能爲一個總體佈局中使用...

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:fillViewport="true" 
android:background="@drawable/background"> 

<!--android:margin="5dp"--> 

<RelativeLayout xmlns:tools="http://schemas.android.com/tools" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="5dp" 
    android:id="@+id/relative_layout" 
    android:background="#4D000000" 
    tools:context="com.daimajia.slider.demo.MainActivity"> 

    <com.daimajia.slider.library.SliderLayout 
     android:id="@+id/slider" 
     android:layout_width="match_parent" 
     custom:pager_animation="Default" 
     custom:indicator_visibility="visible" 
     custom:pager_animation_span="1100" 
     android:layout_height="200dp" /> 

    <com.daimajia.slider.library.Indicators.PagerIndicator 
     android:id="@+id/custom_indicator" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     custom:selected_color="#0095BF" 
     custom:unselected_color="#55333333" 
     custom:shape="oval" 
     custom:selected_padding_left="5dp" 
     custom:selected_padding_right="5dp" 
     custom:unselected_padding_left="5dp" 
     custom:unselected_padding_right="5dp" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     custom:selected_width="6dp" 
     custom:selected_height="6dp" 
     custom:unselected_width="6dp" 
     custom:unselected_height="6dp" 
     android:layout_marginBottom="20dp" /> 

    <com.daimajia.slider.library.Indicators.PagerIndicator 
     android:id="@+id/custom_indicator2" 
     style="@style/AndroidImageSlider_Corner_Oval_Orange" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="20dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/address" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Konstitucijos pr. 7A, Vilnius" 
     android:textColor="#FFFFFF" 
     android:layout_below="@+id/slider" 
     android:layout_marginTop="15dp" /> 

    <ImageButton 
     android:id="@+id/pin" 
     android:layout_width="32dp" 
     android:layout_height="32dp" 
     android:layout_below="@+id/slider" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="5dp" 
     android:background="@drawable/pin" 
     android:layout_marginTop="5dp" /> 

    <View 
     android:id="@+id/divider1" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#433b39" 
     android:layout_below="@id/address" 
     android:layout_marginTop="10dp" /> 

    <TextView 
     android:id="@+id/work_hours" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/divider1" 
     android:text="I - VI 10:00 - 21:00, VII 10:00 - 20:00" 
     android:textColor="#FFFFFF" 
     android:layout_marginTop="10dp" /> 

    <View 
     android:id="@+id/divider2" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#433b39" 
     android:layout_below="@id/work_hours" 
     android:layout_marginTop="10dp" /> 

    <TextView 
     android:id="@+id/description" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/divider2" 
     android:layout_marginTop="10dp" 
     android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." 
     android:textColor="#FFFFFF" /> 

    <FrameLayout 
     android:id="@+id/frame_layout" 
     android:layout_below="@+id/description" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <fragment 
      android:name="com.google.android.youtube.player.YouTubePlayerFragment" 
      android:id="@+id/youtube_fragment" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </FrameLayout> 

    <View 
     android:id="@+id/divider3" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#575350" 
     android:layout_below="@id/frame_layout" 
     android:layout_marginTop="10dp" /> 

    <RelativeLayout 
     android:layout_below="@+id/divider3" 
     android:layout_width="fill_parent" 
     android:id="@+id/rl" 
     android:layout_height="wrap_content"> 

     <RatingBar 
      android:id="@+id/ratingBar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:numStars="5" 
      android:stepSize="1.0" 
      android:rating="0" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:id="@+id/rating_text" 
      android:layout_below="@+id/ratingBar" 
      android:layout_height="wrap_content" 
      android:gravity="center"/> 

    </RelativeLayout> 

    <View 
     android:id="@+id/divider4" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#575350" 
     android:layout_below="@id/rl" /> 

    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal" 
     android:layout_margin="5dp" 
     android:clickable="true"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0" 
      android:text="" /> 

     <ImageButton 
      android:id="@+id/number" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:background="@drawable/phone" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0" 
      android:text="" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0" 
      android:text="" /> 

     <ImageButton 
      android:id="@+id/email" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:background="@drawable/mail" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.0" 
      android:text="" /> 
    </LinearLayout> 

</RelativeLayout> 

</ScrollView> 

期望的結果: enter image description here 它是如何看起來像: enter image description here

+1

採用Android:layout_below = 「ID」 去年的LinearLayout – 2014-12-04 05:43:43

+0

簡單的方式,你必須創建RelativeLayout I nside兩個RelativeLayout。第二個佈局適用於第一個佈局。在FirstLayout添加滑塊和textview和第二個佈局添加兩個圖像按鈕..如果需要兩個佈局之間的分隔符然後添加Seprator-firstrelativelayout-seprator-secondrelativelayout。我認爲這樣幫助 – Sanket990 2014-12-04 05:53:09

回答

0

使用android:layout_below="id of the devider ",因爲我不知道該分頻器是

1

將以下屬性添加到底部LinearLayout;

android:layout_below="@id/divider4" 

更新您的代碼:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:gravity="center" 
    tools:context="com.daimajia.slider.demo.MainActivity"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:fillViewport="true" 
     android:background="@drawable/background"> 

     <!--android:margin="5dp"--> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:id="@+id/relative_layout" 
      android:background="#4D000000"> 

      <com.daimajia.slider.library.SliderLayout 
       android:id="@+id/slider" 
       android:layout_width="match_parent" 
       custom:pager_animation="Default" 
       custom:indicator_visibility="visible" 
       custom:pager_animation_span="1100" 
       android:layout_height="200dp" /> 

      <TextView 
       android:id="@+id/address" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Konstitucijos pr. 7A, Vilnius" 
       android:textColor="#FFFFFF" 
       android:layout_below="@+id/slider" 
       android:layout_marginTop="15dp" /> 

      <ImageButton 
       android:id="@+id/pin" 
       android:layout_width="32dp" 
       android:layout_height="32dp" 
       android:layout_below="@+id/slider" 
       android:layout_alignParentRight="true" 
       android:layout_marginRight="5dp" 
       android:background="@drawable/pin" 
       android:layout_marginTop="5dp" /> 

      <View 
       android:id="@+id/divider1" 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#433b39" 
       android:layout_below="@id/address" 
       android:layout_marginTop="10dp" /> 

      <TextView 
       android:id="@+id/work_hours" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/divider1" 
       android:text="I - VI 10:00 - 21:00, VII 10:00 - 20:00" 
       android:textColor="#FFFFFF" 
       android:layout_marginTop="10dp" /> 

      <View 
       android:id="@+id/divider2" 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#433b39" 
       android:layout_below="@id/work_hours" 
       android:layout_marginTop="10dp" /> 

      <TextView 
       android:id="@+id/description" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/divider2" 
       android:layout_marginTop="10dp" 
       android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." 
       android:textColor="#FFFFFF" /> 

      <FrameLayout 
       android:id="@+id/frame_layout" 
       android:layout_below="@+id/description" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <fragment 
        android:name="com.google.android.youtube.player.YouTubePlayerFragment" 
        android:id="@+id/youtube_fragment" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 
      </FrameLayout> 

      <View 
       android:id="@+id/divider3" 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#575350" 
       android:layout_below="@id/frame_layout" 
       android:layout_marginTop="10dp" /> 

      <RelativeLayout 
       android:layout_below="@+id/divider3" 
       android:layout_width="match_parent" 
       android:id="@+id/rl" 
       android:layout_height="wrap_content"> 

       <RatingBar 
        android:id="@+id/ratingBar" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true" 
        android:numStars="5" 
        android:stepSize="1.0" 
        android:rating="0" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:id="@+id/rating_text" 
        android:layout_below="@+id/ratingBar" 
        android:layout_height="wrap_content" 
        android:gravity="center"/> 

      </RelativeLayout> 

      <View 
       android:id="@+id/divider4" 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#575350" 
       android:layout_below="@id/rl" /> 

      <LinearLayout 
       android:layout_below="@id/divider4" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:orientation="horizontal" 
       android:layout_margin="5dp" 
       android:clickable="true"> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1.0" 
        android:text="" /> 

       <ImageButton 
        android:id="@+id/number" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:background="@drawable/phone" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1.0" 
        android:text="" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1.0" 
        android:text="" /> 

       <ImageButton 
        android:id="@+id/email" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:background="@drawable/mail" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1.0" 
        android:text="" /> 
      </LinearLayout> 

     </RelativeLayout> 

    </ScrollView> 

    <com.daimajia.slider.library.Indicators.PagerIndicator 
     android:id="@+id/custom_indicator2" 
     style="@style/AndroidImageSlider_Corner_Oval_Orange" 
     android:layout_marginBottom="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <com.daimajia.slider.library.Indicators.PagerIndicator 
     android:id="@+id/custom_indicator" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     custom:selected_color="#0095BF" 
     custom:unselected_color="#55333333" 
     custom:shape="oval" 
     custom:selected_padding_left="5dp" 
     custom:selected_padding_right="5dp" 
     custom:unselected_padding_left="5dp" 
     custom:unselected_padding_right="5dp" 
     custom:selected_width="6dp" 
     custom:selected_height="6dp" 
     custom:unselected_width="6dp" 
     custom:unselected_height="6dp"/> 
</LinearLayout> 
+0

,我很高興你試圖幫助我,但是,它仍然不起作用。我的完整版面代碼只是爲了澄清,如果我的想法是正確的:http://pastebin.com/iqvCAyNy – Sharptax 2014-12-04 12:41:26

+0

仍然沒有:/它也不工作... – Sharptax 2014-12-04 13:05:59

+0

再次檢查更新的代碼。 – 2014-12-04 13:16:04

0

地址:

android:layout_below="@id/divider4" 

去年LinearLayout