布局重力问题:android:Layout_Gravity=";完";
我是刚开始学习Android Studio的,在这里遇到了一些麻烦。在这段代码的解释中,我应该看到Hello world贴在右边,但他不想从左边移动。以下是预期结果: 还有我吃的东西布局重力问题:android:Layout_Gravity=";完";,android,android-layout,Android,Android Layout,我是刚开始学习Android Studio的,在这里遇到了一些麻烦。在这段代码的解释中,我应该看到Hello world贴在右边,但他不想从左边移动。以下是预期结果: 还有我吃的东西 将android:orientation=“vertical”添加到您的线性布局中。默认方向为水平。您可以将文本视图重力设置为右侧,并使线性布局方向水平,如下所示 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
将android:orientation=“vertical”
添加到您的线性布局中。默认方向为水平。您可以将文本视图重力设置为右侧,并使线性布局方向水平,如下所示
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
tools:context=".MainActivity"
orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:gravity="right"
android:text="Hello World!" />
</LinearLayout>
尝试以下代码:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:gravity="end"
android:text="Hello World!" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:gravity="end"
android:text="Hello World!" />
</LinearLayout>