从操作栏底部对齐布局

时间:2017-10-07 06:51:42

标签: android layout alignment scrollview

我想从底部,家庭和最近的按钮android对齐我的布局,因为我的内容的结尾位于这些按钮下。我已经在线性布局中使用了约束布局的滚动视图,我在下面附加了它的代码,我尝试了不同的方法,但我无法修复它。 :/ 谢谢你的帮助

后面,主页和最近的按钮

enter image description here

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layoutDirection="rtl"
  android:orientation="horizontal"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="test.NewsPageActivity"
  tools:showIn="@layout/activity_news_page">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="8dp"
    android:textDirection="rtl">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp">

        <TextView
            android:id="@+id/titleNewsPage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:padding="5dp"
            android:text="title"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="11dp"
            android:src="@drawable/image"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/titleNewsPage" />

        <TextView
            android:id="@+id/textNewsPage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:padding="5dp"
            android:text="content"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageView"
            app:layout_constraintVertical_bias="0.0" />

     </android.support.constraint.ConstraintLayout>
 </ScrollView>
</LinearLayout>

2 个答案:

答案 0 :(得分:0)

尝试使用RelativeLayout作为父级,而不是使用android:layout_alignParentBottom="true"在屏幕底部添加您的控件,如下面的示例代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true">

    <LinearLayout
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_launcher" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_launcher" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_launcher" />

    </LinearLayout>

</RelativeLayout>

答案 1 :(得分:0)

将属性final WebView img = new WebView(); final WebEngine Img = img.getEngine(); final DoubleProperty zoomProperty = new SimpleDoubleProperty(200); img.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent e) -> { if (e.getCode() == KeyCode.ADD || e.getCode() == KeyCode.EQUALS || e.getCode() == KeyCode.PLUS) { System.out.println("YES"); zoomProperty.set(zoomProperty.get() * 1.1); } else if(e.getCode()== KeyCode.SUBTRACT||e.getCode() == KeyCode.MINUS ){ System.out.println("YES"); zoomProperty.set(zoomProperty.get() / 1.1); } }); vbox.getChildren().addAll(img); 添加到android:fillViewport="true"

否则使用相对布局并将scrollview属性imageview设置为android:layout_alignParentBottom ..