2016-10-03 52 views
0

我想中心对齐我的厂景对另一视图2和视图2和VIEW1都是自定义尺寸。中心对齐查看关于另一种观点认为

View1 
|------------------------| 
|      | 
|      | 
|  |---------|  | 
|  | View2 |  | 
|  |---------|  | 
|      | 
|------------------------| 

注:视图2是在厂景的中间/中心和厂景不父,我怎么能做到这一点?

我尝试:

<!-- some xml of another parents --> 
<RelativeLayout 
android:layout_width="match_parent" 
    android:layout_height="match_parent" 
> 
<ImageView 
     android:id="@+id/pin" 
     android:layout_width="50dp" 
     android:layout_height="35dp" 
     android:src="@drawable/image" 
     android:layout_centerInParent="true"/> 
</RelativeLayout> 
<!--- long xml ---> 
+2

您已经尝试了什么?请粘贴代码 –

+0

加我的榜样,我忘了你去那里我的朋友 –

回答

0

试试下面的代码...伊茨为我工作

让视图1 = ImageView的; View2 = TextView;

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 


<ImageView 
    android:id="@+id/overlapImage" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="20dp" 

    android:src="@drawable/common_plus_signin_btn_text_dark_pressed" /> 
<TextView 
    android:id="@+id/textViewTittle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:text="Center Text" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textStyle="bold" /> 

</RelativeLayout> 
+0

其中是厂景和视图这种特殊情况下? –

+0

厂景是50dp由50dp和视图2是25dp 25dp,现在这个,失败,如果我在上面的RelativeLayout –

+0

集身高和体重父相对布局,而不是用于厂景 –

相关问题