2013-04-09 4 views
6

हां, यह अभी तक एक और बदलाव है जो SO पर सवाल बढ़ता है। और हाँ, मैं पहले से ही उन सभी संपादनों के सवालों के माध्यम से गुजर चुका हूं। लेकिन यह थोड़ा विशिष्ट है।एंड्रॉइड एडिटेक्स्ट ऑटो टेक्स्ट के साथ बढ़ता है और चीजों को धक्का देता है

यूआई:

enter image description here

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

एक बार उपयोगकर्ता टेक्स्ट दर्ज करना शुरू कर देता है, तो पाठ को समायोजित करने के लिए edittext लंबवत बढ़ता है। साथ ही, बटन को भी बढ़ने के लिए बटन को नीचे धक्का देना चाहिए।

उपयोगकर्ता पूर्ण पाठ देखने के लिए स्क्रीन के माध्यम से लंबवत स्क्रॉल कर सकते हैं। महत्वपूर्ण पाठ दर्ज करने के बाद

यूआई:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/background" 
    android:clipToPadding="false" 
    android:fadingEdge="none" 
    android:fillViewport="true" 
    android:padding="13dp" 
    android:scrollbarStyle="outsideOverlay" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"> 

     <!-- some fixed width image --> 
     <ImageView 
      android:id="@+id/someimage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="4dp" 
      android:src="@drawable/page_white_text" /> 

     <EditText 
      android:id="@+id/some" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/someimage" 
      android:background="@null" 
      android:gravity="top" 
      android:minLines="10" 
      android:minHeight="50dp" 
      android:textColor="#222222" 
      android:textSize="15dp" 
      android:typeface="serif" > 
      <requestFocus /> 
     </EditText> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:baselineAligned="true" 
      android:layout_marginTop="5dp" 
      android:padding="10dp" 
      android:orientation="vertical" > 

      <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button" /> 

     </LinearLayout> 
    </RelativeLayout> 

</ScrollView> 

यह कम या ज्यादा काम करता है:

enter image description here

यहाँ edittext और बटन के नीचे के साथ लेआउट है। लेकिन जब मैं बटन को नीचे धक्का देने के बजाय, अधिक टेक्स्ट में प्रवेश करता हूं। यह हो जाता है के पीछे इसे पसंद:

enter image description here

यहाँ किसी भी मदद की बहुत सराहना कर रहा है। धन्यवाद :)

उत्तर

2

यहाँ मेरी सिफारिश: scrollview के अंदर, एक RelativeLayout जिसमें आप का उपयोग करके android एक निश्चित क्रम में हर तत्व जगह कर सकते हैं डाल: layout_below। अपने संपादन टेक्स्ट के स्वत: बढ़ने के लिए, इस solution का उपयोग करें।

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_gravity="center"> 
<RelativeLayout 
    android:id="@+id/general2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_margin="20sp" > 

    <TextView 
     android:id="@+id/textFirstOpinion" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="@string/titleFirstOpinion" 
     android:textStyle="bold" 
     android:textSize="23sp" 
     android:textColor="#FFFFFF" 
     android:layout_marginTop="10dp" /> 

    <EditText 
     android:id="@+id/fieldFirstOpinion" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/textFirstOpinion" 
     android:minHeight="80sp" 
     android:isScrollContainer="true" 
     android:inputType="textMultiLine" 
     android:textSize="20sp" 
     android:gravity="top|left" /> 

    <Button 
     android:id="@+id/button" 
     android:layout_width="110dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/fieldFirstOpinion" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="37sp" 
     android:textSize="23sp" 
     android:text="@string/textSendButton" 
     android:gravity="center_horizontal" 
     android:padding="10dp" /> 

</RelativeLayout> 
</ScrollView> 
0

कोशिश जोड़ने एंड्रॉयड: layout_below = "@ आईडी/कुछ" जब से तुम बटन पृष्ठ के तल पर होना चाहता हूँ की तरह

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:baselineAligned="true" 
     android:layout_marginTop="5dp" 
     android:padding="10dp" 
     android:orientation="vertical" 
     android:layout_below="@id/some" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button" /> 

    </LinearLayout> 
+0

हाय Vinit, कृपया ans ऊपर पर टिप्पणी देखें:

एक उदाहरण देखते हैं। –

0

अपने LinearLayout में, निम्न पंक्ति जोड़ने

android:layout_below="@+id/some" 
android:layout_centerHorizontal="true" 
android:layout_alignParentBottom="true" 

की तरह अपने LinearLayout कोड यहाँ

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/some" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:baselineAligned="true" 
     android:layout_marginTop="5dp" 
     android:padding="10dp" 
     android:orientation="vertical" > 

इसके अलावा यह सुनिश्चित कर लेंEditText कीपैरामीटर wrap_content पर सेट है यह कोशिश करो और मुझे बताओ कि अगर यह काम करता है या नहीं

+0

आईडी/कुछ में layout_below सेट करना बटन को edittext पर चिपक जाता है। मैं चाहता था कि संपादन को पूर्ण स्क्रीन और बटन को नीचे छड़ी पर दिखाया जाए। यदि संपादन टेक्स्ट में टेक्स्ट स्क्रीन से परे बढ़ता है, तो उसे नीचे दिए गए बटन को धक्का देना चाहिए। यह आंशिक रूप से काम करता है :( –

+0

ठीक है, मैं अपना जवाब संपादित कर रहा हूं –

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