android - Android 中相当于 WPF Grid 的控件

标签 android xml wpf grid equivalent

我觉得问这个问题很愚蠢,但我找不到答案。我习惯了 C# 和 XAML,但我刚开始使用 Android 开发,所以我是 Java 和 XML 的新手,我感到很迷茫。 离WPF Grid最近的控件是什么? 如何通过代码和 XML 定义它?

最佳答案

那么,另一种可能的解决方案是使用LinearLayout,然后根据需要设置子元素的layout_weight,但是一定要设置layout_height子元素为 0dp

例如:

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Space
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".5" />

    <TextView 
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:text="SomeText"
            android:layout_weight=".5"/>

</LinearLayout>

关于android - Android 中相当于 WPF Grid 的控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23860224/

相关文章:

java - Android语音识别与数组

android - 无法使用HoloColorPicker启动 Activity

android - 如何从未捕获的异常处理程序发送电子邮件?

c# - .NET-Assemblies 的默认 (assembly).dll.config 文件有什么用?

c# - 使用 PropertyChangedCallback 支持添加动态属性的最佳实践?

c# - WPF - 在 Window 类中对方法进行单元测试时出现 XamlParseException

android - Activity 的最低 SDK 版本支持

xml - 如何重新定义 StructuredTextEditor 的帮助监听器

java - nbactions.xml 是做什么用的?

c# - 更改命中区域