【发布时间】:2020-01-22 03:45:10
【问题描述】:
我正在编写一个简单的游戏,我希望主屏幕有 3 种布局可供选择,适用于 2 手、右手或左手。
我有一个include 用于控件。但是,我正在努力让layout 以编程方式进行更改。从昨晚开始一直在寻找,但找不到方法,这可能吗?
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:layout_height="match_parent"
tools:context=".GamePlay">
<include
android:layout_width="match_parent"
android:layout_height="88dp"
layout="@layout/hand_two" <!-- this is what needs to change depending on settings -->
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/handLayout"/>
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
-
不,这不可能。我建议您在包含的布局中更改可见性。
标签: android android-studio kotlin