【发布时间】:2014-06-30 10:52:09
【问题描述】:
我已经尝试了几个小时自己解决这个问题,但无法做到。这就是我想要做的:Image of desired layout
“蓝色”矩形是 TextSwitcher 应该包含的区域,但我无法将“重做集”直接放在“上一个项目”上方,将“下一个设置”直接放在“下一个项目”上方“ 按钮。这是我的布局 xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/spinner_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="@+id/spinner_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Spinner
android:id="@+id/spinner_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<TextSwitcher
android:id="@+id/textSwitcherMain"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="40sp"
android:keepScreenOn="true"
android:text="" >
</TextSwitcher>
<Button
android:id="@+id/problematicButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|top"
android:visibility="visible"
android:text="@string/problematic" />
<Button
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:visibility="visible"
android:text="@string/play_1" />
<Button
android:id="@+id/nextSetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:visibility="visible"
android:text="@string/next_set" />
<Button
android:id="@+id/redoSetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:visibility="visible"
android:text="@string/redo_set" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/previousButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/previous_item_button" />
<Button
android:id="@+id/nextButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/next_item_button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.google.android.gms.ads.AdView
ads:adUnitId="**************"
ads:adSize="SMART_BANNER"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center" />
</LinearLayout>
我尝试将 nextButton 和 previousButton 放在 FrameLayout 中,但随后它们分别与 redoSetButton 和 nextSetButton 重叠。此外,nextButton 和 previousButton 应该各自占据 50% 的宽度,所以我不得不将其放入 LinearLayout 中,并尝试将各种组合放入 FrameLayout 中,但我无法以这种方式定位这些按钮。 此外,所有这些按钮都位于 TextSwitcher 的顶部很重要,因为它将具有应该在按钮后面可见的背景图像/颜色。
这是我的第一篇文章。我希望我已经足够详细了。感谢您提前输入。
【问题讨论】:
标签: java android android-layout button position