2012-07-03 11 views
17

मैं Google Play Market से बिल्कुल एक संक्षिप्त दृश्य को कार्यान्वित करना चाहता हूं। यह सामग्री से कई पंक्तियां प्रदर्शित करता है, और एक तीर, और तीर पर टैप करने से पूरी सामग्री प्रकट होती है। क्या यह ExpandableListView के साथ कार्यान्वित किया गया है या कोई अन्य समाधान है?मैं Google Play से एक को संक्षिप्त दृश्य को कैसे कार्यान्वित कर सकता हूं?

स्क्रीन शॉट्स जो मैं ढूंढ रहा हूं उसे हाइलाइट करने से जुड़ा हुआ है। धन्यवाद।

 final TextView descriptionText = (TextView) view.findViewById(R.id.detail_description_content); 
     final TextView showAll = (TextView) view.findViewById(R.id.detail_read_all); 
     showAll.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       showAll.setVisibility(View.INVISIBLE); 

       descriptionText.setMaxLines(Integer.MAX_VALUE); 
      } 
     }); 

एक्सएमएल:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:id="@+id/detail_description_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 

     <TextView 
      android:id="@+id/detail_description_content" 
      android:maxLines="5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 
     <TextView 
      android:id="@+id/detail_read_all" 
      android:clickable="true" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 
</ScrollView> 

महत्वपूर्ण हिस्सा Maxlines और scrollview है enter image description here

+1

यह मदद कर सकता है: http://stackoverflow.com/questions/5165682/how-to-implement-expandable-panels-in-android – 0gravity

+0

हाँ , यह थोड़ा सा मदद करता है, क्योंकि यह जो मैं ढूंढ रहा हूं उसे लागू करता है, लेकिन मुझे आशा थी कि कस्टम लेआउट की तुलना में यह एक आसान समाधान है ... –

उत्तर

29

एक सरल तरीका है। यह धीमी एनीमेशन नहीं देता है (जो एक बोली अधिक जटिल होगा) लेकिन एक त्वरित खुला प्रभाव।

+0

यह कमाल है! –

+0

Awsome आदमी, एक आकर्षण की तरह काम करता है। –

1

मेरी भयानक अंग्रेजी क्षमा करें।

Warpzip प्रतिक्रिया

res/values/strings.xml 
... 
... 
<string name="str_more"><![CDATA[<p><b>This is the header</b><u>(see more ..)</u>]]></string> 
<string name="str_less"><![CDATA[<p><b>This is the header</b><u>(less ..)</u>]]></string> 
<string name="str_details"><![CDATA[<p>A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.A long string of text that do not want to show all the time.</p>]]></string> 
... 
... 

हमारे layoutIn हमारे लेआउट में आधार पर, हम एक ऊर्ध्वाधर LinearLayout के साथ एक scrollview शामिल कर सकते हैं (या एक छोटे से काम एक RelativeLayout के साथ)। इन में:

<TextView 
      android:id="@+id/txtvw_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:text="@string/str_more" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/txtvw_detail" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/txtvw_tituloEntreTodos" 
      android:text="@string/str_details" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

अंत में हमारे गतिविधि

view = inflater.inflate(R.layout.f_entretodos, container, false); 
     info = (TextView) view.findViewById(R.id.txtvw_header); 
     fullinfo = (TextView) view.findViewById(R.id.txtvw_detail); 
     info.setText(Html.fromHtml(getString(R.string.str_more))); 
     fullinfo.setText(Html.fromHtml(getString(R.string.str_detail))); 
     fullinfo.setVisibility(View.GONE); 
     info.setOnClickListener(new OnClickListener(){ 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       if (fullinfo.isShown()){ 
        fullinfo.setVisibility(View.GONE); 
        info.setText(Html.fromHtml(getString(R.string.str_more))); 
       }else{ 
        fullinfo.setVisibility(View.VISIBLE); 
        info.setText(Html.fromHtml(getString(R.string.str_less))); 
       } 
      } 

     }); 
संबंधित मुद्दे

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