2015-12-09 17 views
5

को संकुचित करने के अंदर पाठ के साथ बटन जोड़ने के लिए निम्न लेआउट कैसे प्राप्त करें। मैं ऐड बटन के बिना हासिल कर सकता था। लेकिन एडीडी बटम जोड़ने के लिए और बटन को स्क्रॉल करते समय छवि के लंबन के साथ गायब होना चाहिए।एंड्रॉइड: टूलबार

मुझे जो मिला वह फ्लोटिंग एक्शन बटन में टेक्स्ट जोड़ने की सुविधा नहीं है। मुझे केवल बटन का उपयोग करना है। जोड़ें बटन बिना

enter image description here

मेरे XML लेआउट:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layoutplace1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/coordinatorLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appBarLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true"> 

      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/collapsing_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="150dip" 
       android:fitsSystemWindows="true" 
       app:contentScrim="?attr/colorPrimary" 
       app:expandedTitleMarginBottom="20dp" 
       app:expandedTitleMarginEnd="64dp" 
       app:expandedTitleMarginStart="48dp" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

       <ImageView 
        android:id="@+id/header" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:layout_collapseMode="parallax" /> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        app:layout_collapseMode="pin" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 


      </android.support.design.widget.CollapsingToolbarLayout> 

     </android.support.design.widget.AppBarLayout> 

     <FrameLayout 
      android:id="@+id/framelayout" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_gravity="bottom" 

      app:layout_anchor="@+id/appBarLayout" 
      app:layout_anchorGravity="bottom" 
      app:layout_collapseMode="none"> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabLayout" 
       android:layout_width="match_parent" 
       android:layout_height="50dp" 
       android:background="#ffffff" 
       android:gravity="bottom" 
       android:textAllCaps="false" 
       android:theme="@style/MyCustomTabLayout" 
       app:tabGravity="center" 
       app:tabIndicatorColor="#574ec1" 
       app:tabIndicatorHeight="2dp" 
       app:tabMode="scrollable" 
       app:tabSelectedTextColor="#574ec1" 
       app:tabTextColor="#8A000000" /> 

     </FrameLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewPager" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:paddingBottom="56dp" 
      android:layout_marginTop="50dp" 

      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_viewplace1" 
     android:layout_height="match_parent" 
     android:layout_width="wrap_content" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="false" 
     app:itemTextColor="#8A000000" 
     app:itemIconTint="#8A000000" 
     app:menu="@menu/drawer_view" /> 
</android.support.v4.widget.DrawerLayout> 

इसके अलावा पाठ: "उडुपी श्रीकृष्ण मंदिर" जो डबल लाइनों में दिखाई देता है। क्या यह संभव है।

मैं

collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 
     collapsingToolbar.setTitle("Udupi Sri krishna Temple"); 

का उपयोग कर शीर्षक जोड़ने लेकिन शीर्षक केवल आंशिक रूप से और शो से पता चलता ...

इसके बजाय मैं इसे कई पंक्तियों में प्रदर्शित करना चाहते हैं। यह संभव

उत्तर

11

आप बटन और छवि इस

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appBarLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="150dip" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginBottom="20dp" 
     app:expandedTitleMarginEnd="64dp" 
     app:expandedTitleMarginStart="48dp" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:id="@+id/header" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="bottom|end" 
      app:layout_collapseMode="parallax" 
      android:orientation="horizontal"> 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button"/> 
     </LinearLayout> 
    </android.support.design.widget.CollapsingToolbarLayout> 

</android.support.design.widget.AppBarLayout> 

की तरह अपने मुख्य स्क्रॉल सामग्री में जोड़ सकते हैं आप TextView, Button जोड़ सकते हैं इस कोड

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/scroll" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clipToPadding="false" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

</android.support.v4.widget.NestedScrollView> 
+0

चेकिंग जो मैं चाहता हूं उसके करीब दिखता है। क्या आप यह भी बता सकते हैं कि पाठ को ठीक से –

+0

टेक्स्ट प्रॉपर्टी कैसे प्राप्त करें? क्या आप बटन के साथ टेक्स्टव्यू भी चाहते हैं? –

+0

हां। पूरी चीज "उडुपी श्री कृष्ण मंदिर" और बटन कैसे प्राप्त करें। –

0

या किसी बात यह है कि आप चाहते हैं करने के लिए रखा है ढहने योग्य लेआउट पर दिखाएं।

<android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="150dip" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginBottom="20dp" 
     app:expandedTitleMarginEnd="64dp" 
     app:expandedTitleMarginStart="48dp" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

    <ImageView 
      android:id="@+id/header" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_collapseMode="parallax" > 

<android.support.v7.widget.Toolbar 
         android:id="@+id/toolbar" 
         android:layout_width="match_parent" 
         android:layout_height="?attr/actionBarSize" 
         app:layout_collapseMode="pin" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 
       <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         > 
         <TextView 
           android:id="@+id/toolbar_title_text" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content" 
          /> 
          <Button 
          android:id="@+id/btntest" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
         ... /> 

         ....... 
       </LinearLayout> 

</android.support.v7.widget.Toolbar> 
    </android.support.design.widget.CollapsingToolbarLayout> 
+0

छुपा नहीं रहा है। मैंने कोशिश की। पाठ और बटन केवल शीर्ष ऊंचाई (? Attr/actionBarSize) में जोड़े जाते हैं। वे –

+0

दिखाए गए चित्र की तरह नहीं जोड़े गए हैं, मैं सुझाव देता हूं कि टूलबार के अंदर जोड़ने के बजाय इसे बाहर जोड़ें और collapsingtoolbarlayout –

+0

के भीतर काम करना ठीक है –

संबंधित मुद्दे