2013-10-29 3 views
8

안녕하세요, 광고 배너가 발생하는 곳이기 때문에 화면 맨 아래에서 화면 하단까지 조금씩 스크롤보기가 있습니다. Google 정책으로 인해 이러한 요소 (버튼과 배너 사이에 있음) 사이에 일부 픽셀이 있어야합니다. 지금까지 나는 dp에서 값을 설정하는 것으로 이것을했다. 하지만 기기가 다르면 일부 고소질 휴대 전화에서 광고와 스크롤보기 사이에 큰 격차가 생깁니다. 이것은 내가 설정하고 싶은 이유안드로이드는 XML로 화면 크기를 얻습니다.

<ScrollView 
android:layout_height="(Screen_height-banner)-5px" 

(물론 심지어이 더 코드 없기 때문에,이 방법으로 그것을 시도하지 않은,하지만 난 그게 꽤 잘 나는 할 계획 무엇을 요약 한 생각)

답장을 보내 주셔서 감사합니다.

답변

2

layout_above, 당신은 RelativeLayout를 사용하여이 작업을 수행하고 사용할 수있는 사용 alignmentsmargins . 귀하의 경우

대신 스크롤 뷰를 확장해야 할 경우 XML이

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

     <ScrollView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:layout_marginBottom="5dp"> 

</RelativeLayout > 

을 것 Screen_height 배너는 화면 높이를 나타냅니다 당신은 끝에서 5dp 분리기를 바닥에 그것을 놓고 만들고 싶어 그것의 위치는 xml이 될 것입니다

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding_bottom="5dp"> 

     <ScrollView 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent"> 

</RelativeLayout > 
+0

API API 레벨 8 이상은 "fill_parent"를 "match_parent"로 대체했습니다. – Antonin

1

사용하십시오 RelativeLayout의는 5px의 여백을 설정하고 런타임에 실행되지 않기 때문에 당신은 XML에서 화면 크기를 쿼리 할 수 ​​없습니다

2

사용자 가중치 매개 변수를 사용할 수 있습니다. 두 레이아웃 0.5의 가중치를 설정하면이 레이아웃의 화면 너비가 같아집니다.

<LinearLayout 
    android:id="@+id/alt_panel" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/orta_panel" > 

    <LinearLayout 
     android:id="@+id/altsol_panel" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="0.5" 
     android:gravity="center_horizontal" 
     android:orientation="vertical" > 


    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/altsag_panel" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_weight="0.5" 
     android:gravity="center_horizontal" 
     android:orientation="vertical" > 


    </LinearLayout> 
</LinearLayout> 
관련 문제