2017-08-11 9 views
5

मैं एंड्रॉइड में ConstraintLayout और एंड्रॉइड के लिए नौसिखिया के लिए नया हूं। मेरा एक सवाल है। ConstraintLayout के अंदर LinearLayout का उपयोग करने की सलाह दी जाती है? उदाहरण के लिए:क्या एंड्रॉइड में ConstraintLayout के अंदर LinearLayout का उपयोग करने की सलाह दी जाती है?

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    app:srcCompat="@drawable/landing_screen" 
    android:layout_height="match_parent" 
    tools:context="com.braigolabs.braigo.landing.LandingActivity"> 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:scaleType="centerCrop" 
     app:srcCompat="@drawable/landing_screen" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintVertical_bias="1.0" 
     app:layout_constraintHorizontal_bias="1.0" 
     tools:layout_constraintTop_creator="1" 
     tools:layout_constraintRight_creator="1" 
     tools:layout_constraintBottom_creator="1" 
     tools:layout_constraintLeft_creator="1"/> 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     tools:layout_editor_absoluteX="0dp" 
     tools:layout_editor_absoluteY="51dp"> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="66dp" 
      android:layout_marginStart="66dp" 
      android:gravity="center" 
      android:text="@string/login_welcome_braigolabs"    android:textAppearance="@style/TextAppearance.AppCompat.Large" 
      tools:layout_editor_absoluteX="93dp" 
      tools:layout_editor_absoluteY="403dp"/> 

     <Button 
      android:id="@+id/login_button" 
      style="@style/Widget.AppCompat.Button.Colored" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:elevation="2dp" 
      android:text="@string/login_login_button_title" 
      android:textAllCaps="false" 
      tools:layout_editor_absoluteX="116dp" 
      tools:layout_editor_absoluteY="543dp"/> 
    </LinearLayout> 
</android.support.constraint.ConstraintLayout> 

भी उत्सुक पता करने के लिए डेवलपर्स के बीच ConstraintLayout कैसे लोकप्रिय है?

उत्तर

9

क्या यह ConstraintLayout के अंदर LinearLayout का उपयोग करने की सलाह दी जाती है?

नहीं ... आमतौर पर।

सामान्य तौर पर, ConstraintLayout के पीछे विचार यह है कि यह आपको ConstraintLayout अंदर घोंसला करने के लिए किसी अन्य ViewGroup रों बिना अपने बच्चों के सभी स्थित कर सकते है। इस प्रकार, मैं कहूंगा कि यह सलाह नहीं है।

हालांकि, वहाँ कुछ चीजें हैं जो एक LinearLayout कि एक ConstraintLayout नहीं (ज्यादातर विचारों की भारित रिक्ति से संबद्ध) कर सकते हैं कर सकते हैं, और इसलिए यदि आप अपने लेआउट में इन विशेष कोने मामलों की जरूरत है, आप ऐसा नहीं करेंगे LinearLayout पर वापस आने के अलावा कोई विकल्प है।

डेवलपर्स के बीच ConstraintLayout कितना लोकप्रिय है?

ConstraintLayout अपेक्षाकृत नया है, लेकिन यह काफी शक्तिशाली है और निश्चित रूप से कुछ है जो आपको स्वयं को परिचित करना चाहिए। यह हमेशा नौकरी के लिए सही उपकरण नहीं होगा, लेकिन यह आपको अक्सर ऐसे लेआउट बनाने की अनुमति देगा जो आप अन्यथा घंटों खर्च करेंगे।

मैं व्यापक गोद लेने के आंकड़ों से बात नहीं कर सकता, लेकिन मैं कह सकता हूं कि मैंने इस साइट पर ConstraintLayout के सही उपयोग के बारे में बहुत से प्रश्न देखे हैं, इसलिए दुनिया भर में स्पष्ट रूप से devs इसके साथ काम करना शुरू कर रहे हैं।

+0

बिल्कुल सही। धन्यवाद @ बेन। क्यों कोई डाउनवोट डालता है? यह एक काफी प्रासंगिक सवाल है। – TechBee

+0

मैं निश्चित रूप से नहीं कह सकता, लेकिन मेरा मानना ​​है कि आपका प्रश्न व्यापक रूप से बोल रहा है, एक विशिष्ट प्रोग्रामिंग समस्या पेश करने के बजाय _opinion_ मांग रहा है। इसे आम तौर पर ऑफ-विषय माना जाता है। –

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

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