Android 如何在嵌套的线性和相对布局中对齐图标和显示文本作为选框?
我的问题是: 如何对齐布局,如下图所示 我如何在文本视图中接收文本,并使用类似于字幕文本的动画来代替从右向左滚动的欢迎回来John Doe 客观的 但是我无法在这里对齐图标,这就是我得到的:截图2 概念: 这些是图标,每当收到通知或消息时,都会以红色圆圈显示数字 在右边,我想显示文本,它取决于作为消息或通知形式的文本接收的文本。考虑到它是动态的,它经常变化 我在这一部分上结巴了,无法解决它。如果有人能帮我解决这个问题,我将不胜感激!! 谢谢Android 如何在嵌套的线性和相对布局中对齐图标和显示文本作为选框?,android,android-layout,android-studio,Android,Android Layout,Android Studio,我的问题是: 如何对齐布局,如下图所示 我如何在文本视图中接收文本,并使用类似于字幕文本的动画来代替从右向左滚动的欢迎回来John Doe 客观的 但是我无法在这里对齐图标,这就是我得到的:截图2 概念: 这些是图标,每当收到通知或消息时,都会以红色圆圈显示数字 在右边,我想显示文本,它取决于作为消息或通知形式的文本接收的文本。考虑到它是动态的,它经常变化 我在这一部分上结巴了,无法解决它。如果有人能帮我解决这个问题,我将不胜感激!! 谢谢 对于字幕代码,您可以查看 我不确定,但如果你让你的文本
对于字幕代码,您可以查看
我不确定,但如果你让你的文本视图宽度与家长匹配,应该可以,但我不是100%确定。不确定为什么它被否决:谢谢Maitri,你的建议很有帮助:!!谢谢你的字幕资源!!我在找这个。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_landing_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.66"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1.22"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#737D8C"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:background="#3c424c"
android:orientation="horizontal">
<ImageView
android:id="@+id/message_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="@drawable/add_event" />
<ImageView
android:id="@+id/notification_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="@drawable/add_notice" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:background="#3c424c"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="5dp"
android:text="Welcome Back, John Doe !"
android:textColor="#ffffff"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.34" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_landing_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.66"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1.22"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#737D8C"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
android:background="#3c424c"
android:orientation="horizontal">
<ImageView
android:id="@+id/message_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="@drawable/add_event" />
<ImageView
android:id="@+id/notification_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="@drawable/add_notice" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60"
android:background="#3c424c"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="5dp"
android:text="Welcome Back, John Doe !"
android:textColor="#ffffff"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.34" />
</LinearLayout>