2015-08-28 55 views
-3

我試圖創建Android的代碼如下所示的模板,任何人都可以幫我做這之間的圖像,不能夠把按鈕

enter image description here

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Username"/> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:password="true" 
     android:hint="Password"/> 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="70dp"> 
      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:gravity="center" 
       android:background="@color/blue"> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_marginRight="130dp" 
        android:text="Login In" 
        android:textStyle="normal" 
        android:textSize="15dp" 
        android:textColor="@android:color/white" 
        android:background="@color/blue"/> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:text="Sign Up" 
        android:textStyle="normal" 
        android:textSize="15dp" 
        android:textColor="@android:color/white" 
        android:background="@color/blue"/> 
      </LinearLayout> 
      <LinearLayout 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:gravity="center"> 
       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@mipmap/ic_launcher"/> 
      </LinearLayout> 
     </RelativeLayout> 

以上是我寫的代碼實現這一點,但看起來像我做錯了,誰能幫我理解這一點。

回答

1

在LinearLayout中添加android:layout_centerHorizontal="true"

 <LinearLayout 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_centerHorizontal="true" 
      android:gravity="center"> 
      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:src="@mipmap/ic_launcher"/> 
     </LinearLayout>