2013-02-07 14 views
6

में जोड़ने में असमर्थ मैं एक एप्लिकेशन में विजेट बनाने की कोशिश कर रहा हूं, निम्नलिखित लेआउट का उपयोग कर रहा हूं। मैंने विजेट के दूसरे भाग में स्क्रॉल व्यू जोड़ने की कोशिश की है। मैं ऐसा करने में असमर्थ हूं, जब मैंने टैग हटा दिए, विजेट प्रदर्शित हो रहा है, लेकिन टैग के साथ, एंड्रॉइड विजेट लोड करने में असमर्थ है। मैं इसके साथ दो दिनों तक अपने सिर खरोंच कर रहा हूँ। मुझे समझ में नहीं आता कि मैं क्या गलत कर रहा हूं?<ScrollView> को एंड्रॉइड ऐप विजेट लेआउट

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@android:color/background_light" 
    > 

     <RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@android:color/background_dark" 
      android:id="@+id/widgetHeader" 
      > 

      <Button 
       android:background="@drawable/icon_quickword" 
       android:id="@+id/widgetBtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_margin="5sp" 
      /> 

      <TextView android:text="@string/widget_title1" 
       android:id="@+id/widget_title1" 
       android:textSize="18sp" 
       android:textStyle="bold" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:textColor="@android:color/white" 
       android:layout_toRightOf="@id/widgetBtn" 
       android:layout_marginLeft="2sp" 
       /> 

      <TextView android:text="@string/widget_title2" 
       android:id="@+id/widget_title2" 
       android:textSize="15sp" 
       android:textStyle="italic" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:textColor="@android:color/white" 
       android:layout_toRightOf="@id/widgetBtn" 
       android:layout_below="@id/widget_title1" 
       android:layout_marginLeft="3sp" 
       /> 


     </RelativeLayout> 

      <ScrollView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 

      <LinearLayout 
       android:id="@+id/widgetContent" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:background="@android:color/white" 
       > 

       <TextView android:text="@string/widget_content_info1" 
        android:id="@+id/widget_content_info1" 
        android:textStyle="bold" 
        android:textSize="16sp" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:textColor="@android:color/black" /> 

       <TextView android:text="@string/widget_content_info2" 
        android:id="@+id/widget_content_info2" 
        android:textSize="14sp" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:textColor="@android:color/black" /> 

       <TextView android:text="@string/widget_content_info3" 
        android:id="@+id/widget_content_info3" 
        android:textSize="14sp" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:textColor="@android:color/black" /> 

      </LinearLayout> 
     </ScrollView> 

</LinearLayout>                    
+1

एक ListView उपयोग बजाय –

उत्तर

2
 <ScrollView 
      android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
     > 

    <LinearLayout 
     android:id="@+id/widgetContent" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:background="@android:color/white" 
     > 

     <TextView android:text="@string/widget_content_info1" 
      android:id="@+id/widget_content_info1" 
      android:textStyle="bold" 
      android:textSize="16sp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:textColor="@android:color/black" /> 

     <TextView android:text="@string/widget_content_info2" 
      android:id="@+id/widget_content_info2" 
      android:textSize="14sp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:textColor="@android:color/black" /> 

     <TextView android:text="@string/widget_content_info3" 
      android:id="@+id/widget_content_info3" 
      android:textSize="14sp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:textColor="@android:color/black" /> 

    </LinearLayout> 

    **</ScrollView>** 
+0

उर खत्म नहीं स्क्रॉल होड़ डब्ल्यू टैग – duggu

+0

मुझे टैग का उपयोग नहीं करना चाहिए, लेकिन क्यों? क्या होगा यदि मैं बस स्क्रीन के बीच में स्क्रॉल करने योग्य दृश्य देना चाहता हूं, ऊपर और नीचे भागों को तय कर रहा हूं? – Amol

0

सभी विशेषताओं इस्तेमाल करने के बाद अंत टैग के साथ अपने दृश्य को बंद करें। अंत टैग के साथ अपना ScrollView बंद करें।

<ScrollView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:id="@+id/widgetContent" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:background="@android:color/white" 
     > 
    </LinearLayout> 

</ScrollView> 
+0

मैंने जोड़ा है, अभी भी कुछ गलत है, नए लेआउट के साथ अद्यतन प्रश्न। – Amol

+0

कुछ और टेक्स्ट जोड़ें इसे आजमाएं। क्योंकि इसकी लंबाई कम है। – MuraliGanesan

4

मुझे लगता है कि scrollview Android एप्लिकेशन-विजेट में समर्थित नहीं है (विगेट्स कि, होम स्क्रीन में चला जाता है कि यदि आप क्या मतलब है!)। समर्थित दृश्यों की सूची here

+0

स्क्रॉलिंग किनारे (क्षैतिज स्क्रॉलव्यू) समर्थित नहीं है। स्क्रॉलव्यू, मेरा मानना ​​है कि समर्थित है। –

+1

मैंने एपविजेट में स्क्रॉल व्यू के साथ प्रयास किया, लेकिन विजेट भी लोड नहीं हो रहा है। और आधिकारिक दस्तावेज स्क्रॉल दृश्य को समर्थित के रूप में सूचीबद्ध नहीं करता है –

1

स्क्रॉल दृश्य केवल एक ही बच्चा होस्ट कर सकते हैं, बेहतर एक ListView का उपयोग

1

आप केवल 1 सूची आइटम (अपने लेआउट) सूची दृश्य here के लिए

प्राप्त नमूने के साथ ListView उपयोग कर सकते हैं

और संशोधित ListProvider.java

public int getCount() { 
return 1; 
} 
public RemoteViews getViewAt(int position) { 
    RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.your_origin_layout); 
    remoteView.setTextViewText(R.id.content, "your Text"); 
    // add other pocess here 
    return remoteView; 
} 
संबंधित मुद्दे