正如线程名称所示,我面临元素重叠的问题。我需要制作类似页脚的东西,它始终位于布局的底部并且不会与元素重叠。我在下面发布我的布局。我认为问题在于我如何定位评级栏和线性布局,它应该位于底部。
P.S 不要怪我使用相对布局的方式, slider 应该有一个父相对布局,而 ScrollView 只能用于一种通用布局...
<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>
想要的结果: 它实际上是什么样子:
最佳答案
将以下属性添加到底部 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>
关于java - 布局 - 图像不在底部且重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27286993/