/
Android Creating a Wrapper
Android Creating a Wrapper
You can choose to create a view inside the layout or create the view programmatically and add it to the layout later.
View in Layout File
This code goes inside the root of your layout file.
# activity_main.xml
...
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
</LinearLayout>
...
Get this view from an activity or fragment, a way to do it could be:
# MainActivity.kt
val wrapper = findViewById(R.id.wrapper)
View Programmatically
# MainActivity.kt
// Get the root layout of the activity
val parent = findViewById<ViewGroup>(R.id.main_layout) as RelativeLayout
// Create your custom layout
val wrapper = LinearLayout(this)
wrapper.orientation = LinearLayout.HORIZONTAL
// parameters for the wrapper inside a relative layout
val params = RelativeLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
params.addRule(RelativeLayout.CENTER_HORIZONTAL)
wrapper.layoutParams = params
// add the wrapper to the main layout
parent.addView(wrapper)
, multiple selections available,
Related content
1.0.0 - SDK - Creating a Wrapper
1.0.0 - SDK - Creating a Wrapper
More like this
Banner
Banner
More like this
Outstream
Outstream
More like this
1.0.0 - Infinite Scroll
1.0.0 - Infinite Scroll
More like this
Infinite Scroll
Infinite Scroll
More like this
Android Tagged Wrappers
Android Tagged Wrappers
More like this