android - CheckBox 和 ImageButton 没有使用 Android 水平显示?

标签 android xml checkbox

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
   <LinearLayout 
       android:id="@+id/risktablerowcheckbox_layout"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal"
       android:layout_marginLeft="10dp"
       android:layout_marginRight="10dp"
       android:layout_marginTop="5dp"
       android:weightSum="5"
       android:visibility="gone">
    <LinearLayout 

        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="vertical">

        <CheckBox 
        android:id="@+id/risktablerow_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"

        android:text="fdf dfsdfsd dfsdfsdf dfsdf sdfsdf sddfs  "
        android:textSize="14sp"
        android:textStyle="bold"
        android:drawableLeft="@android:color/transparent"
        android:drawablePadding="2dp"/> 

     </LinearLayout>
     <LinearLayout 
        android:id="@+id/risktablerowbutton_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_gravity="center"
        android:layout_weight="1">

<ImageButton 
        android:id="@+id/riskinfo_btn" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/info_risk"
        android:layout_marginTop="5dp"/>
 </LinearLayout>
 </LinearLayout>
</TableRow>

一旦我在复选框文本中放置大文本,它就会占用这么多空间,并且我的按钮不会在纵向模式下显示在屏幕上,而在横向模式下按钮是可见的,这里是布局。有人可以看看代码有什么问题吗上面的代码?

Portrait Mode

horizontal Mode

after adding Keshav answer getting this layout 请让我知道如何对齐编辑文本和图像按钮以及微调器和图像按钮的基线

最佳答案

将此用于您的复选框和图像按钮:

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <CheckBox
        android:id="@+id/risktablerow_checkbox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_weight="5"
        android:drawableLeft="@android:color/transparent"
        android:drawablePadding="2dp"
        android:text="fdf dfsdfsd dfsdfsdf dfsdf sdfsdf sddfs sfsfsfsada "
        android:textSize="14sp"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/riskinfo_btn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_weight="1"
        android:background="@drawable/ic_launcher" />
</LinearLayout>

关于android - CheckBox 和 ImageButton 没有使用 Android 水平显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20564104/

相关文章:

android - 查找 Android 应用程序的 "name"

android - 从android中的上下文获取 Activity

XML 架构 - elementFormDefault 是不合格的,但使用了命名空间前缀

android - 在 Android Pie 上启动 context.startService(intent)

android - 将 BroadcastReceiver 注册到 Widget(Context 对象的区别)

checkbox - Reactjs - 控制多个复选框

java - 如果单元格包含复选框,如何获取 JTable 的内容

javascript - 如果选中复选框,则启用 EditorFor

android - 我们如何在android中的textview中显示百分比符号

c# - 在 C# 中使用相对路径在 Internet Explorer 中打开 xml 文档