2014-07-27 4 views
0

나는 안드로이드에 두 개의 숫자 선택 도구를 만들려고합니다. 그러나 나는 그것들을 양쪽에 가운데에 놓으려고 노력한다. 상대 레이아웃과 선형 레이아웃을 섞으려고했으나 문제를 해결할 수 없었습니다.Android 센터 하단 numberpickers

이미지는 버튼이 현재 어떻게 배치되어 있는지 보여줍니다. 빨간색 사각형은 단추를 표시하는 방법을 보여줍니다.

희망을 보내 주시면 감사하겠습니다.

<RelativeLayout 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" 
    tools:context="com.pvdl.ndwatch.NDwatchActivity$PlaceholderFragment" > 

<ImageView 
    android:id="@+id/background" 
    android:layout_width="wrap_content" 
    android:layout_height="300dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    android:scaleType="centerCrop" 
    android:src="@drawable/background" /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/nd_text" 
    android:textColor="@color/red" 
    android:textStyle="bold" /> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="90dp" 
    android:layout_height="90dp" 
    android:layout_marginLeft="20dp" 
    android:layout_marginTop="20dp" 
    android:src="@drawable/ic_launcher" /> 

<View 
    android:layout_width="match_parent" 
    android:layout_height="5dp" 
    android:layout_marginLeft="150dp" 
    android:layout_marginTop="90dp" 
    android:background="#00ABCC" /> 

<TextView 
    android:id="@+id/title" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="150dp" 
    android:layout_marginTop="20dp" 
    android:text="@string/title" 
    android:textColor="#404041" 
    android:textSize="60sp" /> 

<TextView 
    android:id="@+id/title2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="200dp" 
    android:layout_marginTop="30dp" 
    android:text="@string/title2" 
    android:textColor="#404041" 
    android:textSize="50sp" /> 

<RelativeLayout 
    android:id="@+id/frame" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" > 
</RelativeLayout> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="270dp" 
    android:layout_height="270dp" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:background="@android:color/transparent" 
    android:indeterminate="false" 
    android:max="100" 
    android:progress="0" 
    android:progressDrawable="@drawable/circular_progress_bar" /> 

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:layout_alignBottom="@+id/background" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="60dp" 
    android:background="@android:color/transparent" 
    android:onClick="onNDstart" 
    android:scaleType="fitXY" 
    android:src="@drawable/custom_button" /> 

<Chronometer 
    android:id="@+id/chronometer1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/imageButton1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="15dp" 
    android:background="@android:color/transparent" 
    android:text="Chronometer" 
    android:textColor="#000000" 
    android:textSize="70sp" 
    android:textStyle="bold" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/background" 
    android:layout_marginBottom="40dp" 
    android:layout_centerHorizontal="true" 
    android:text="@string/start" 
    android:textColor="@color/red" 
    android:textStyle="bold" />   

<NumberPicker 
    android:id="@+id/numberPicker2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_weight="1" 
    android:entries="@array/shutter_times" 
    /> 

<NumberPicker 
    android:id="@+id/numberPicker1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_weight="1" 
    android:entries="@array/nd_values" 
    android:gravity="bottom" /> 

</RelativeLayout> 
+0

의미있는 (즉, NumberPicker 요소의 부모 요소) 레이아웃을위한 전체 XML을 제공하십시오 – FreewheelNat

+0

지금 전체 XML을 제공했습니다. –

답변

1

enter image description here이에 XML을 변경

: 당신이 버튼 사이의 공간을 원하는 경우에

<RelativeLayout ...> 

    .... 

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

     <NumberPicker 
     android:id="@+id/numberPicker2" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:entries="@array/shutter_times" /> 

     <NumberPicker 
     android:id="@+id/numberPicker1" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:entries="@array/nd_values" /> 
    </LinearLayout> 

</RelativeLayout> 

그냥 left buttonpaddingRightright buttonpaddingLeft에 같은 값을 추가 .

희망이 도움이됩니다.