Issue
I have my main activity. Inside this main activity I want to create an unknown number of layouts that each one of them include one button. I want smart way to do it - make the layout one time and than use it a lot of time.
What is a good way to do it? Thanks
Solution
Make One Layout Resource File Using Below Code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:layout_marginTop="@dimen/_15sdp"
android:gravity="center"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp" />
<Button
android:layout_width="match_parent"
android:layout_height="@dimen/_35sdp"
android:layout_marginStart="@dimen/_5sdp"
android:layout_marginTop="@dimen/_20sdp"
android:layout_weight="1"
android:gravity="center"
android:text="Submit"
android:textColor="@color/white"
android:textSize="@dimen/_10sdp" />
</LinearLayout>
And In Your Main Activity Layout You Can Use Only
<include layout="@layout/layoutresourcefilename"/>
Answered By - Mit Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.