Android 如何将视图组放置在屏幕底部
您好,我正在设计我的应用程序的一个屏幕,其中我需要将完整的最后一个线性布局放置在屏幕底部,这意味着该线性布局的图像视图应显示在底部,但当前它们未放置,请您查看原因。做这件事的正确方法是什么Android 如何将视图组放置在屏幕底部,android,android-layout,Android,Android Layout,您好,我正在设计我的应用程序的一个屏幕,其中我需要将完整的最后一个线性布局放置在屏幕底部,这意味着该线性布局的图像视图应显示在底部,但当前它们未放置,请您查看原因。做这件事的正确方法是什么 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="matc
<ScrollView 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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo_dans_ma_rue" />
<com.example.customview.TextViewWithCustomFont
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_screen_app_tex_vertical_margin"
android:gravity="center"
android:text="@string/app_name"
android:textSize="@dimen/login_screen_app_text_size" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/login_main_drawable" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/facebookButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/fb_button" />
<ImageView
android:id="@+id/twitterButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/twitter_button" />
<ImageView
android:id="@+id/emailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/email_button" />
</LinearLayout>
</LinearLayout>
</ScrollView>
目前它看起来像这样,我希望所有三个图像视图都应该出现在屏幕底部
平板电脑7英寸
平板电脑10英寸
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/loading" />
<com.example.customview.TextViewWithCustomFont
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/app_name"
android:textSize="15dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/loading" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/facebookButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/loading" />
<ImageView
android:id="@+id/twitterButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/loading" />
<ImageView
android:id="@+id/emailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/loading" />
</LinearLayout>
</LinearLayout>
你真的需要ScrollView吗?若并没有,请尝试此操作,否则滚动视图将尝试获取视图的最小高度,并且我的占位符将被展平
另一种方法是将按钮置于ScrollView下
我看到的最后一个解决方案是,如果您确实需要scrollView中的任何内容,请尝试生成您自己的线性布局,然后自己放置视图。我尝试了您的解决方案,但它不起作用,仍然显示与您删除的scrollView相同的内容?正如我所说的,scrollView强制尽可能低的高度,如果您删除它,我的解决方案将无法工作。这就是为什么我问你是否真的需要scrollView。是的,我删除了scrollView。如果你遗漏了什么,复制我所有的代码,然后用这种方式检查。根linearLayout的高度设置为与父项匹配,如果我将其设置为“包装”内容,则它将不起作用,所以您可能错过了该细节?
// try this way,hope this will help you...
<ScrollView 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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.audiostreet.LoginActivity$PlaceholderFragment" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo_dans_ma_rue" />
<com.example.customview.TextViewWithCustomFont
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_screen_app_tex_vertical_margin"
android:gravity="center"
android:text="@string/app_name"
android:textSize="@dimen/login_screen_app_text_size" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/login_main_drawable" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/facebookButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/fb_button" />
<ImageView
android:id="@+id/twitterButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/twitter_button" />
<ImageView
android:id="@+id/emailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttons_vertical_margin"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/email_button" />
</LinearLayout>
</LinearLayout>
</ScrollView>