android-在新的一行中设置 relativelayout

问题描述

在新的一行中设置 relativelayout

关于 layout 的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/button_background_dark_default"
    android:gravity="center_vertical"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:paddingRight="?android:attr/scrollbarSize" >
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:layout_marginLeft="15dip"
        android:layout_marginRight="6dip"
        android:layout_marginTop="6dip"
        android:layout_weight="1" >
        <TextView
            android:id="@+android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:singleLine="true"
            android:text="222"
            android:textAppearance="?android:attr/textAppearanceLarge" />
        <TextView
            android:id="@+android:id/summary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@android:id/title"
            android:layout_below="@android:id/title"
            android:maxLines="4"
            android:text="222ssss"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="?android:attr/textColorSecondary" />
    </RelativeLayout>
</LinearLayout>

现在我想重复这个步骤再设置另外一个布局,那么在新的一行中如何实现呢?之前每次设置都在相同的一行,而不是新的一行。

<TextView
    android:id="@+android:id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:singleLine="true"
    android:text="222"
    android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
    android:id="@+android:id/summary"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@android:id/title"
    android:layout_below="@android:id/title"
    android:maxLines="4"
    android:text="222ssss"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="?android:attr/textColorSecondary" />

解决方案

可以把重复的这个布局独立出来,在需要重复的父控件上include进来。
当然你可以可以用代码来写,使用for循环来添加,这个比较麻烦些

时间: 2024-09-17 04:49:36

android-在新的一行中设置 relativelayout的相关文章

android开发如何在程序中设置双卡手机来电铃声

问题描述 android开发如何在程序中设置双卡手机来电铃声 如题,对单卡手机的我知道. 就是不知道双卡手机有没有什么不一样的地方. 解决方案 http://www.android-study.net/listxx.aspx?id=658 这个博客 写的还不错

android-Android 怎么在一个网页链接中设置变量 这个格式是怎么样的

问题描述 Android 怎么在一个网页链接中设置变量 这个格式是怎么样的 就比如http://www.wwwwwwddd.com/api/get_post?post_type=news&id=??? 在这个链接中,如何在ID=后的???中设置变量 使得在其他方法中的参数能传过去. 解决方案 String id = null; xxxx?post_type=news&id="+id; 解决方案二: xxxx?post_type=news&id=123 解决方案三: 求大神

如何在 android 中设置一个用户名和密码文件

问题描述 如何在 android 中设置一个用户名和密码文件 我设置了两个edittext和一个button.我想设置一个特殊的用户名和密码,当我点击按钮时,如果用户名和密码正确,就会打开一个新的intent,否则显示一个toast.我用的下面的代码显示不同的toast,但是没有运行出来,总是显示 ""incorrect"".如何解决这个问题呢? b.setOnClickListener(new OnClickListener() { public void onC

android中设置控件获得焦点

android中,要使控件获得焦点,需要先setFocus,再requestFocus. 以Button为例:                 btn.setFocusable(true);                 btn.setFocusableInTouchMode(true);                 btn.requestFocus();                 btn.requestFocusFromTouch(); //获得失去焦点的监听器 btn.setOn

布局-Android自定义控件在scrollview中设置高度不起作用,已经重写了 onMeasure方法

问题描述 Android自定义控件在scrollview中设置高度不起作用,已经重写了 onMeasure方法 布局: android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <RelativeLayout android:layout_width="match_parent&q

Android动态设置RelativeLayout控件的高度例子

在做项目的时候其中一个需求是要求banner图的宽和高是1:1所以我需要获取手机屏幕的宽度然后动态的把高度值设置为手机屏幕宽度的值在这项目中就是设置RelativeLayout的高度值代码如下 mRllayoutBanner = (RelativeLayout) findViewById(R.id.rl_banner); WindowManager wm = this.getWindowManager(); int width = wm.getDefaultDisplay().getWidth(

Android 5.0 Lollipop 新版本中那些值得关注的新功能

Android 5.0 Lollipop 新版本中那些值得关注的新功能 时间:2014-11-04 10:15 来源:PingWest 作者:光谱 Android,统治了全世界七成设备的操作系统--很可惜,并不是大一统,而是王子王孙群雄割据的状态--当然,今天我们讨论的不是统一和割据孰优孰劣的问题.除了美国进入冬令时之外,今天 Android 家族至少有一条重要消息值得关注:Google 自行开发的原生 Android 操作系统,也被誉为最纯净的 Android,将在美国时间 11 月 3 日正

应用-android中设置支持javascript会引入xss变量到你的程序中,请检查清楚

问题描述 android中设置支持javascript会引入xss变量到你的程序中,请检查清楚 Using setJavaScriptEnabled can introduce XSS vulnerabilities into you application, review carefully. 如何理解上面这句英语啊?? 解决方案 你指的是在webView上设置支持JavaScript么? 解决方案二: @SuppressLint("SetJavaScriptEnabled") 忽略

在AndroidManifest.xml文件中设置Android程序的启动界面方法

  比如Android的Login程序和Android的Helloworld程序,但是却总不能正确运行一个正确的程序,郁闷了很久,终于在一次一次的测试后成功的在Android模拟器中运行了自建项目的程序.总结程序启动界面的设置经验如下: 在 MyEclipse建立的Android项目中,找到AndroidManifest.xml文件,双击打开. 设置程序运行后首先启动Login界面的AndroidManifest.xml文件代码如下: <?xml version="1.0" en