2017-02-17 1 views
0

두 개의 구성 요소 인 SquareLayout과 두 번째 구성 요소가 RecyclerView 인 LinearLayout이 하나 있는데 SquareLayout이 화면 중앙에 있고 RecyclerView가 화면 하단에 있어야하지만 이유는 모르지만 중력 그것을 위해 일하지 않는다. 나는 안드로이드에 새로운 것이지만 나는 내 질문에 분명히 희망한다. 다음은 내 .xml 파일입니다.LinearLayout on center

<LinearLayout 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" 
    android:orientation="vertical" > 

<com.example.layouts.SquareLayout 
     android:id="@+id/llSelectedLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center" 
     ></com.example.layouts.SquareLayout> 

    <android.support.v7.widget.RecyclerView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/rvImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 

</LinearLayout> 
+0

있는 LinearLayout 내가 생각 할 수는 없지만, RelativeLayout의는 –

+0

그것은 나를 위해 작동합니다, 귀하의 제안에 감사드립니다 수 있습니다. –

답변

0

이렇게하려면 LinearLayout 대신 RelativeLayout을 사용하십시오.

<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" 
    android:orientation="vertical"> 

    <com.example.gridcollagelayouts.SquareLayout 
     android:id="@+id/llSelectedLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:centerInParent="true" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rvImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:below="@+id/llSelectedLayout" /> 

</RelativeLayout> 
+0

답변에서 Recyclerview의 xmlns : android = "http://schemas.android.com/apk/res/android"및 xmlns : tools = "http://schemas.android.com/tools"를 제거 할 수 있습니다. – raktale

+0

@raktale이 (가) 삭제되었습니다. 감사합니다. –

+0

감사합니다. 상대 레이아웃을 사용하여 작동합니다. –