2017-08-02 167 views
0

我不確定如何正確對齊圖像視圖;帶有「選擇處理」按鈕文本的箭頭圖像。我試圖爲imageview設置保證金,但似乎並未解決問題。任何人都可以幫忙嗎?圖像視圖與按鈕不對齊

下面是圖片和佈局代碼的屏幕截圖。

enter image description here

Request_Appointment.xml

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:background="@drawable/background"> 
     <include 
      android:id="@+id/toolbar" 
      layout="@layout/sublayout_Toolbar" /> 
     <android.support.v4.widget.DrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/drawer_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <ScrollView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:paddingBottom="35dp"> 
        <LinearLayout 
         android:id="@+id/request_HospitalLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="25dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical"> 
         <TextView 
          android:id="@+id/request_HospitalLabel" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/dark_blue" 
          android:text="@string/hospital" /> 
         <EditText 
          android:id="@+id/request_HospitalField" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="10dp" 
          android:editable="false" 
          android:textColorHint="@color/dark_blue" 
          android:textColor="@color/dark_blue" 
          android:fontFamily="sans-serif-light" 
          android:background="@drawable/editText_line" /> 
        </LinearLayout> 
        <LinearLayout 
         android:id="@+id/request_DateLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical" 
         android:layout_below="@id/request_HospitalLayout"> 
         <TextView 
          android:id="@+id/request_DateLabel" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/dark_blue" 
          android:text="@string/pref_date" /> 
         <EditText 
          android:id="@+id/request_DateField" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="10dp" 
          android:maxLines="1" 
          android:hint="@string/select_date" 
          android:focusable="false" 
          android:editable="false" 
          android:textColorHint="@color/dark_blue" 
          android:textColor="@color/dark_blue" 
          android:fontFamily="sans-serif-light" 
          android:background="@drawable/editText_line" /> 
        </LinearLayout> 
        <LinearLayout 
         android:id="@+id/request_DentistLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical" 
         android:layout_below="@id/request_DateLayout"> 
         <TextView 
          android:id="@+id/request_DentistLabel" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/dark_blue" 
          android:text="@string/pref_dentist" /> 
         <Spinner 
          android:id="@+id/request_DentistSpinner" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="10dp" 
          android:spinnerMode="dropdown" 
          android:prompt="@string/select_dentist" 
          android:background="@drawable/editText_line" /> 
        </LinearLayout> 
        <LinearLayout 
         android:id="@+id/request_SessionLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical" 
         android:layout_below="@id/request_DentistLayout"> 
         <TextView 
          android:id="@+id/request_SessionLabel" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/dark_blue" 
          android:text="@string/pref_session" /> 
         <Spinner 
          android:id="@+id/request_SessionSpinner" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="10dp" 
          android:spinnerMode="dropdown" 
          android:prompt="@string/select_session" 
          android:background="@drawable/editText_line" /> 
        </LinearLayout> 
        <LinearLayout 
         android:id="@+id/request_TreatmentLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical" 
         android:layout_below="@id/request_SessionLayout"> 

        <Button 
         android:id="@+id/request_TreatmentsBtn" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/request_SessionLayout" 
         android:layout_weight="1" 
         android:textColor="@color/dark_blue" 
         android:text="@string/select_treatments" 
         android:textAllCaps="false" 
         android:background="@color/transparent" /> 

        <ImageView 
         android:id="@+id/appt_ArrowImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:src="@drawable/ic_arrow" 
         android:layout_gravity="right" 
         android:layout_alignParentRight="true" 
         android:layout_marginRight="30dp" 
         android:scaleX="0.75" 
         android:scaleY="0.75" /> 
        </LinearLayout> 
        <LinearLayout 
         android:id="@+id/request_RemarksLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:orientation="vertical" 
         android:layout_below="@id/request_TreatmentLayout"> 
         <TextView 
          android:id="@+id/request_RemarksLabel" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textColor="@color/dark_blue" 
          android:text="@string/remarks" /> 
         <EditText 
          android:id="@+id/request_RemarksField" 
          android:layout_width="match_parent" 
          android:layout_height="150dp" 
          android:layout_marginTop="10dp" 
          android:padding="5dp" 
          android:gravity="top|left" 
          android:textColor="@color/dark_blue" 
          android:fontFamily="sans-serif-light" 
          android:background="@color/.8_white" /> 
        </LinearLayout> 
        <Button 
         android:id="@+id/request_SubmitBtn" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/request_RemarksLayout" 
         android:layout_marginTop="35dp" 
         android:layout_marginLeft="50dp" 
         android:layout_marginRight="50dp" 
         android:textColor="@color/white" 
         android:text="@string/submit" 
         android:textAllCaps="false" 
         android:background="@color/blue" /> 
       </RelativeLayout> 
      </ScrollView> 
      <android.support.design.widget.NavigationView 
       android:id="@+id/nav_view" 
       android:layout_height="match_parent" 
       android:layout_width="wrap_content" 
       android:layout_gravity="start" 
       android:background="@color/light_blue" /> 
     </android.support.v4.widget.DrawerLayout> 
    </LinearLayout> 
+0

將'request_TreatmentLayout'線性佈局從'vertical'更改爲'horizo​​ntal'。 – Piyush

+0

順便說一句,您已在'LinearLayout'中使用'layout_below'和'android:layout_alignParentRight =「true」'不適用於它。它僅在'RelativeLayout'中使用。 – Piyush

回答

1

改變你的request_TreatmentLayout方向android:orientation="vertical"android:orientation="horizontal"這樣

<LinearLayout 
    android:id="@+id/request_TreatmentLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="35dp" 
    android:layout_marginLeft="50dp" 
    android:layout_marginRight="50dp" 
    android:orientation="horizontal" 
    android:layout_below="@id/request_SessionLayout"> 

    <Button 
     android:id="@+id/request_TreatmentsBtn" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/request_SessionLayout" 
     android:layout_weight="1" 
     android:textColor="@color/dark_blue" 
     android:text="@string/select_treatments" 
     android:textAllCaps="false" 
     android:background="@color/transparent" /> 

    <ImageView 
     android:id="@+id/appt_ArrowImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_like" 
     android:layout_gravity="right" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="30dp" 
     android:scaleX="0.75" 
     android:scaleY="0.75" /> 
</LinearLayout> 
0

嘗試代碼:

<RelativeLayout 
        android:id="@+id/request_TreatmentLayout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="35dp" 
        android:layout_marginLeft="50dp" 
        android:layout_marginRight="50dp" 
        android:orientation="vertical" 
        android:layout_below="@id/request_SessionLayout"> 

       <Button 
         android:id="@+id/request_TreatmentsBtn" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:textColor="@color/dark_blue" 
         android:text="@string/select_treatments" 
         android:textAllCaps="false" 
         android:background="@color/transparent"/> 

       <ImageView 
         android:id="@+id/appt_ArrowImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:src="@drawable/ic_arrow" 
         android:layout_gravity="right" 
         android:layout_alignParentRight="true" 
         android:layout_marginRight="15dp" 
         android:layout_below="@id/request_TreatmentsBtn" 
         android:scaleX="0.75" 
         android:scaleY="0.75"/> 
      </RelativeLayout>