A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
Welcome to our Microsoft Q&A platform!
Is there any way to simply say something like "Use Layout A if the screen is wider than x, otherwise use Layout B"?
Try to get the parent layout of the dynamic view in the OnCreate method, then detect the device's width to add the view.
<LinearLayout
android:id="@+id/testLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
//add the view according to the device's size in the OnCreate method
var testLayout = FindViewById<LinearLayout>(Resource.Id.testLayout);
if (xxx)
{
testLayout.AddView(text);
}
else
{
testLayout.AddView(_button);
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.