2014-09-07 4 views
0

Google Plus의 Chrome 또는 작업 표시 줄에 주소 표시 줄을 숨기거나 표시하는 기능을 구현하는 방법을 알고 싶습니다.웹보기를 스크롤 할 때 맞춤 제목 레이아웃을 숨기거나 표시하는 방법

사용자 정의 타이틀 레이아웃이 있는데, 스크롤 할 때 웹보기를 숨길 때 표시되고 위로 스크롤 할 때 표시됩니다.

다음은 내 레이아웃의 xml 파일입니다.

그냥 제목 표시 줄 표시/숨기기를 원하는 경우
<?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" > 

    <RelativeLayout 
     android:id="@+id/top_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="@color/article_title" 
     android:gravity="center" 
     android:padding="10dip" > 

     <LinearLayout 
      android:id="@+id/date_layout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_centerInParent="true" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/date" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#535353" 
       android:gravity="center" 
       android:paddingLeft="5dip" 
       android:paddingRight="5dip" 
       android:text="4/10" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="@color/white" /> 

      <TextView 
       android:id="@+id/year" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/white" 
       android:gravity="center" 
       android:paddingLeft="5dip" 
       android:paddingRight="5dip" 
       android:text="2013" 
       android:textAppearance="?android:attr/textAppearanceSmall" 
       android:textColor="#0B729D" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/title_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_toRightOf="@+id/date_layout" 
      android:orientation="vertical" 
      android:paddingLeft="10dip" 
      android:paddingRight="10dip" > 

      <TextView 
       android:id="@+id/title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Title" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 

      <TextView 
       android:id="@+id/category" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="subtitle" /> 
     </LinearLayout> 
    </RelativeLayout> 

    <WebView 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/ad_layout" 
     android:layout_below="@id/top_layout" /> 

</RelativeLayout> 

답변

0

:.

액션 바로 당신의 제목 부분 레이아웃을 넣고, 다음 (.hide 사용할 수 있습니다)/쇼() 당신이 필요로 할 때. 실행 바에

설정 XML 파일 : 귀하의 답변에 대한

LayoutInflater inflater = (LayoutInflater) getActionBar() 
    .getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE); 

View customActionBarView = inflater.inflate(R.layout.YOUR_XML_FILE, null); 

ActionBar actionBar = getActionBar(); 
actionBar.setDisplayOptions(
    ActionBar.DISPLAY_SHOW_CUSTOM, 
    ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME 
      | ActionBar.DISPLAY_SHOW_TITLE); 
actionBar.setCustomView(customActionBarView, 
    new ActionBar.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT, 
      ViewGroup.LayoutParams.MATCH_PARENT)); 
+0

감사합니다. 하지만 이미 공유 또는 즐겨 찾기와 같은 다른 정보를 표시하기 위해 작업 표시 줄을 사용합니다. 따라서, 나는 그것을 구현하는 다른 방법이 필요하다. – user3209403

+0

사용자 정의 작업 표시 줄은 간단한 방법입니다 .. 어쩌면 더 많은 정보를 표시하도록 2 배 높이를 설정할 수 있지만 Google 플러스와 같이 별도로 제어 할 수는 없습니다. – user3680200

+0

또는 다음을 사용해야 할 수도 있습니다. https://developer.android.com/reference/android/view/animation/TranslateAnimation.html – user3680200

관련 문제