2011-12-01 1 views
0

슬라이딩 드로어 위젯을 사용하여 Android 애플리케이션에서 뷰를 작성합니다. 내 자신의 사용자 지정 핸들을 구현했습니다 (메뉴 단추의 행이 서랍의 내용을 변경 한 다음 openAmination을 활성화합니다). slidingdrawer와 함께 제공되는 표준 핸들을 비활성화 할 수 있었지만 완전히 제거하고 싶습니다. XML 또는 자바의 표준 가시성 물건의슬라이딩 서랍 핸들 숨기기

없음 핸들을 제거/숨어 작동하지 않습니다 :

<SlidingDrawer android:layout_width="fill_parent" 
     android:id="@+id/slidingDrawer1" 
     android:layout_height="fill_parent" 
     android:handle="@+id/handle" 
     android:content="@+id/content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:allowSingleTap="false" 

     > 

      <Button android:layout_width="wrap_content" 
      android:text="Close" 
      android:layout_height="wrap_content" 
      android:id="@+id/handle" 
      android:visibility="gone" //DOES NOT WORK 
      </Button> 

      <LinearLayout android:id="@+id/content" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#FFFFFF"> 
      </LinearLayout> 
     </SlidingDrawer> 

가 나는 또한 자바에서보기를 가져오고 같은 일을 시도했지만 역시 작동하지 않습니다.

View h = findViewById(R.id.handle); 
h.setVisibility(View.GONE); 

slideDrawer 클래스를 확장하고 직접 만들려고했으나 여전히 핸들이 필요합니다. 어쨌든 기본 핸들이없는 슬라이딩 서랍이 있습니까?

----- 솔루션 ----

draw = (SlidingDrawer)findViewById(R.id.slidingDrawer1); 


    //Close the draw if opened when the user touches elsewhere on the screen 
    draw.setOnTouchListener(new OnTouchListener(){ 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      if(draw.isOpened()) 
      ((SlidingDrawer)v).animateOpen(); 
      return false; 
     }}); 

//Open the draw by external button 
    ((Button) findViewById(R.id.quiz_button)).setOnClickListener(
      new Button.OnClickListener(){ 
        @Override 
        public void onClick(View arg0) { 
         draw.animateOpen(); 
        } }); 

슬라이딩 무승부 뷰의 XML했다 :

<SlidingDrawer android:layout_width="fill_parent" android:allowSingleTap="false" android:id="@+id/slidingDrawer1" android:content="@+id/content" android:handle="@+id/handle" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> 
      <Button android:layout_height="wrap_content" android:layout_width="0px" android:visibility="invisible" android:text="Close" android:id="@+id/handle"></Button> 
      <LinearLayout android:id="@+id/content" android:gravity="center" android:background="#4FFFFF44" android:layout_width="fill_parent" android:layout_height="76dp"></LinearLayout> 
     </SlidingDrawer> 

많은 감사 샘

+1

'Button'의'layout_widht'를'0px'로 설정해보십시오. –

+0

은 충분히 잘 작동합니다! 이 경우 –

+0

여기에서 SlidingDrawer의 슬라이딩 기능을 사용하려면 어떻게해야합니까? 나는 또한 똑같은 것을 시도하고있다. 버튼을 사용하지 않으면 내 슬라이딩 동작이 콘텐츠에 대해 작동하지 않습니다. 해결책이 있으면 알려주세요. – Raj

답변

2

I 많은 시간 동안 노력하고 손잡이를 제거하지 못했습니다. 내가 할 수있는 최선의 방법은 뷰 창에서 멀리 이동하는 것입니다. 이미 슬라이딩 드로어 클래스를 확장했다면 쉽습니다. onLayout 방법에

라인

handle.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); 

을 찾아 화면의 방법으로 기본적으로

handle.layout(10000, 10000, 10000, 10000); 

그것의 단지 설정의 위치를 ​​변경합니다.

2

문제를 해결하는 더 좋은 방법을 찾았습니다.

핸들 자체는 숨기지 말고 내용은 숨기십시오. ImageView를 핸들로 사용했지만 ImageView를 포함하는 LinearLayout으로 변경했습니다.

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

    <ImageView 
     android:id="@+id/handleImage" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/sliding_drawer_handle" /> 
</LinearLayout> 

이제 handleImage.setVisibility (View.INVISIBLE는) onAnimationEnd에서 잘 작동합니다. 나는이 같은 문제가

+0

이 나에게 도움이됩니다. 감사합니다. –

1

:) 도움이

희망은, 내가 클릭에서 SlidingDrawer을 표시하는 개인 버튼이 있기 때문에 핸들을 표시하지 않습니다. 그래서 핸들 높이를 0dp로 설정하여 해결합니다.

 <ImageButton 
      android:id="@+id/cash_menuGruop_handle" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_contetn" 
      android:layout_height="0dp"/> 
0
<Button 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:id="@+id/handle" 
     android:visibility="gone" //DOES NOT WORK 
     </Button> 
  1. 사용 높이와 폭 0dp , 개폐 사용 핸들 : 이 내 핸들 코드입니다.performclick(); 나를 위해 노력하고있다.