2012-07-02 2 views
0

대화 상자 레이아웃을 만드는 데 문제가 있습니다. 스크롤 단추가 항상 아래쪽에 표시되지만 스크롤 막대 크기가 너무 커지면 대화 상자를 표시하려고합니다. 화면 아래쪽에있는 버튼을 누릅니다.아래쪽에 스크롤 막대와 영구 단추가있는 대화 상자가 있습니다.

부모의 하단에있는 버튼을 true로 설정하면 원하는 효과를 얻을 수 있지만 scrollview에 내용이 거의없는 경우 많은 빈 공간이있는 큰 대화 상자가 표시됩니다. 여기

내가 현재

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

    <ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

     <TextView 
      android:id="@+id/staCalCompany" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dp" 
      android:layout_marginLeft="15dp" 
      android:layout_marginTop="30dp" 
      android:text="Company Name" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:textColor="#ff2525" 
      android:textSize="25sp" /> 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/staCalStart" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="15dp" 
       android:text="Start:" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#ff2525" /> 

      <TextView 
       android:id="@+id/staCalStartDisp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:text="Start Time" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dp" > 

      <TextView 
       android:id="@+id/staCalEnd" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="15dp" 
       android:text="End:" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#ff2525" /> 

      <TextView 
       android:id="@+id/staCalEndDisp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:text="End Time" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 

     <TextView 
      android:id="@+id/staCalSubDisp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginLeft="15dp" 
      android:text="Name" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:textColor="#ff2525" /> 

     <TextView 
      android:id="@+id/staCalDesc" 
      android:layout_width="285dp" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dp" 
      android:layout_marginLeft="15dp" 
      android:text="Description" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 
     </ScrollView> 

<RelativeLayout 
      android:id="@+id/linearLayout3" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:layout_gravity="bottom|center_horizontal" 
      android:gravity="center_horizontal" 
      android:layout_below="@+id/scrollView1"> 

      <ImageButton 
       android:id="@+id/calIconSync" 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_marginLeft="20dp" 
       android:background="@drawable/calendar_plus" /> 

      <ImageButton 
       android:id="@+id/btnStaCalClose" 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_alignParentRight="true" 
       android:layout_marginRight="20dp" 
       android:background="@drawable/closepopup" /> 
     </RelativeLayout> 
이 모두 가로 및 세로 모드에서 올바르게 표시하려고 노력하지만 하나가 작동 할 때, 다른 하나는 수행하지 않은 것입니다.

이 작업을 수행하는 방법에 대한 제안 사항은 무엇입니까?

답변

0

이러한 경우 나는 아래의 다른 보이지 않는 더미 버튼을 만들고 내 "실제"버튼이 올바르게 배치되도록 정렬합니다.

더미 버튼이 화면에서 튀어 나오면 실제 버튼이 그 위에 있습니다. 화면에 물건이 거의없는 경우 더미 버튼은 하단에 있고 "실제"버튼은 중간에 있습니다.

너비가 "1dp"이고 필요한 높이만큼 "보이지 않는"버튼을 만드십시오. 하지만 ANdroid 감각으로 볼 수있게 두십시오.

EDIT : 목록보기의 맨 아래에 정렬하고 maxHeight를주는 상대보기를 만들 수 있습니다. 이 상대적인보기 아래에 단추를 정렬하십시오. 목록보기가 작 으면 목록 바로 아래에 단추가 배치됩니다. 목록보기가 길면 상대보기가 maxHeight를 초과하고 화면에 계속 표시되므로 단추가 maxHeight 바로 아래에있게됩니다. relativeView의 maxHeight가 버튼의 화면 하단에 충분한 공간을 남겨 둡니다.

Display display = getWindowManager().getDefaultDisplay(); 
Point size = new Point(); 
display.getSize(size); 
int screenHheight = size.y; 

희망하는 데 도움이 : 그것은 당신이 screenHeight에 따라 장치의 화면 크기를 얻기 위해 이것을 사용하고 maxHight을 조정할 수있는 화면 크기의 버튼에 대한 충분한 여지가 있도록

은의 maxHeight을 조정하려면 또한 귀하의 경우 ...

+0

그래도 scrollview가 충분히 커지면 실제 버튼이 너무 잘 보이지 않을 수도 있습니다. – tyczj

+0

나를 위해 작동하지 않았다. – Genry

관련 문제