【发布时间】:2021-05-11 08:18:48
【问题描述】:
这个问题是关于移动应用程序UI设计的,我在网上搜索了很长时间,没有找到任何令人满意的解释 - 所以我决定把它带到这里。我正在使用 Android Studio (Java),我有一个由 LinearLayout 组成的导航栏,其中在我的 activity_home.xml 内包含 5 个导航按钮,我想在该导航栏的中间(不是角落)。看起来像这样的东西:
我将在这里分享一些我已经拥有的以及我想要的代码和图像。
代码:
activity_home.xml:
<LinearLayout
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/navigation_bar_border"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".20"
android:background="@drawable/user_icon"
android:clickable="true" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".20"
android:background="@drawable/notifications_icon"
android:clickable="true" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".20"
android:background="@drawable/add_icon"
android:clickable="true" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".20"
android:background="@drawable/search_icon"
android:clickable="true" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".20"
android:background="@drawable/home_icon"
android:clickable="true" />
</LinearLayout>
navigation_bar_border.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
<gradient
android:startColor="@color/light_dark_color"
android:endColor="@color/light_dark_color"
android:angle="90"/>
</shape>
</item>
</layer-list>
我现在拥有的:
我想要达到的目标:
我该怎么做?
【问题讨论】:
标签: android android-layout android-linearlayout