2010-06-10 12 views
7

मैं एडिटटेक्स्ट विजेट के अंदर, ड्रैबल्स की तुलना में अन्य एम्बेड करने का तरीका जानने का प्रयास कर रहा हूं। विशेष रूप से उदाहरण मैं सोच रहा हूँ Google Buzz विजेट से है:एक संपादन टेक्स्ट के अंदर एक दृश्य (बटन के साथ, आदि) को कैसे एम्बेड करें?

screenshot (कोई इनलाइन छवि, एक newb माफ करना, मैं हूँ)

यह आकस्मिक प्रेक्षक वहाँ एक पूरी लेआउट वस्तु है कि प्रतीत होता है एडिटटेक्स्ट के निचले हिस्से में पिन किया गया, जिसमें एक छवि दृश्य, एक टेक्स्ट व्यू, और एक बटन शामिल है।

किसी को भी यह पता है कि इसे कैसे खींचें? या क्या हमें लगता है कि यह संपादन टेक्स्ट का एक कस्टम उप-वर्ग है?

उत्तर

0

मुझे लगता है कि उन्होंने जो किया है वह उनके लेआउट के लिए पृष्ठभूमि बना रहा है जो एक संपादन टेक्स्ट की तरह दिखता है। फिर उन्होंने बैकग्राउंड बंद होने और बटन आने के साथ एक एडिटटेक्स्ट जोड़ा।

+0

के रूप में TextView बदलने के लिए, यद्यपि यदि आप ट्रैकबॉल के साथ फोकस चेन के साथ खेलते हैं, तो ऐसा लगता है कि ऐसा नहीं है। – Hugh

15

एडिटटेक्स्ट + बटन + ... यह editText के साथ formatText के साथ फ़्रेमलाइट है और लेआउट_ग्रैविटी के साथ बटन: "नीचे"। कुछ इस तरह:

<?xml version="1.0" encoding="utf-8"?> <!-- Main Layout (may be relative or whatever --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <!-- Layout for edittext and button --> 
    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:lines="5"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|right" 
      android:layout_margin="5dip" 
      android:text="Overflow"/> 

    </FrameLayout> 

    <!-- More layouts ..... --> </RelativeLayout> 
+2

अच्छा जवाब- यह सही चिह्नित किया जाना चाहिए। –

1

आप EditText में एम्बेड बटन के लिए फ्रेम लेआउट का उपयोग कर सकते हैं, यहाँ मैं EditText में एम्बेड TextView के लिए नमूना कोड दे, मुझे लगता है कि संभव है बस बटन

<FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="40px" 
     android:layout_y="35px" 
     >   

    <EditText android:id="@+id/twt_post_content" android:layout_gravity="center_vertical" 
     android:layout_width="320dp" android:layout_height="140dp" 
     android:paddingTop="5dp" android:imeOptions="actionDone" 
     android:gravity="left" android:focusableInTouchMode="true" 
     android:maxLength="140" android:ellipsize="end" /> 
      <TextView 
       android:text="123" 
       android:paddingLeft="270dp"  
       android:paddingTop="100dp" 
       android:layout_alignParentRight="true" 
       android:id="@+id/twt_content_count" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"    
       android:textColor="@color/red" 
       android:layout_gravity="center"    
       android:background="@color/transparent"/>  
       </FrameLayout>   
संबंधित मुद्दे