2013-01-17 2 views
1

[여기에 이미지 설명을 입력하십시오] [1] 배경의 고정 된 크기로 장치의 절반 화면을 채우는 텍스트 뷰를 설정해야합니다. 나는이 코드를 시도하지만 나는 할 수 없다. 목표는 : 하프 스크린, 위로 나는 이미지를, 텍스트 뷰는 보여줍니다.background textview 하프 스크린

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000000" 
android:orientation="vertical" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/luna" 
     android:textSize="15pt" /> 

    <ScrollView 
     android:id="@+id/scrollView10" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:background="#000000" > 

     <TextView 
      android:id="@+id/textView10" 
      android:layout_width="match_parent" 
      android:layout_height="320dp" 
      android:background="#000000" 
      android:gravity="center" 
      android:textColor="#ffffff" 
      android:textSize="14sp" 
      android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl" 
      android:autoLink="web|email" 
      android:textStyle="italic" /> 
    </ScrollView> 
</LinearLayout> 

<Button 
    android:id="@+id/button10" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Chiudi" /> 

    </LinearLayout> 

답변

2

가중치를 추가하면됩니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000000" 
android:orientation="vertical" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/luna" 
    android:textSize="15pt" 
    android:layout_weight="1"/> 

<ScrollView 
    android:id="@+id/scrollView10" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center" 
    android:background="#000000" 
    android:layout_weight="1" > 

    <TextView 
     android:id="@+id/textView10" 
     android:layout_width="match_parent" 
     android:layout_height="320dp" 
     android:background="#000000" 
     android:gravity="center" 
     android:textColor="#ffffff" 
     android:textSize="14sp" 
       android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl" 
     android:autoLink="web|email" 
     android:textStyle="italic" /> 
</ScrollView> 
</LinearLayout> 

<Button 
android:id="@+id/button10" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:text="Chiudi" /> 

</LinearLayout> 
+0

답장을 보내 주셔서 감사합니다. 괜찮아 보이지만 이미지 손실 비율 –

+0

난 여기에 ScrollView 필요 없어 생각합니다. TextView의 텍스트가 높이를 초과하면 textView에서 스크롤을 활성화 할 수 있기 때문에 –

+0

감사합니다! 이미지가 비율을 유지하지 않습니다. 내가 고칠 수 있니? –

0

확인이 : 내가 상대 레이아웃 내부 선형 레이아웃을 변경 한

. 원하는대로 결과를 줄 것입니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#000000" 
    android:orientation="vertical" > 

    <RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <ScrollView 
      android:id="@+id/scrollView10" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_gravity="center" 
      android:background="#000000" > 

      <TextView 
       android:id="@+id/textView10" 
       android:layout_width="match_parent" 
       android:layout_height="320dp" 
       android:autoLink="web|email" 
       android:background="#000000" 
       android:gravity="center" 
       android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl" 
       android:textColor="#ffffff" 
       android:textSize="14sp" 
       android:textStyle="italic" /> 
     </ScrollView> 

     <ImageView 
      android:id="@+id/img" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@id/scrollView10" 
      android:background="@drawable/luna" 
      android:textSize="15pt" /> 
    </RelativeLayout> 

    <Button 
     android:id="@+id/button10" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Chiudi" /> 

</LinearLayout> 

먼저 scrollview를 정의했습니다. 그리고 나서 match_parent 크기로 ImageView를 정의했습니다. 그래서 화면의 나머지 모든 공간을 차지합니다. 이 방법은 이미지 비율도 적절합니다. 희망이 도움이됩니다.

+0

답장을 보내 주셔서 감사합니다. 이미지가 다시 비율을 유지하지 않습니다. –

+0

@ PolHallen, 스냅 샷을 게시 할 수 있습니까? 그건 내 일에 잘 작동 했거든. –

+0

내가보기에 스크린 샷을 추가했는데, 달이 원처럼 보이지는 않습니다. 감사 –