android布局技巧之类微信对话输入布局
2023-09-14 08:56:49 时间
这是第一种情形。由于涉及到ImageView,想保持图片原比例不便使用LinearLayout的weight属性。
解决办法:
1.外层套一个RelativeLayout
2.三个控件分别装进3个LinearLayout中,假如id分别为leftlayout,midlayout,rightlayout
leftlayout属性:android:layout_width="wrap_content"
rightlayout属性:android:layout_width="wrap_content"
midlayout属性: android:layout_width="match_parent" android:layout_toLeftOf="@+id/rightlayout"
android:layout_toRightOf="@+id/leftlayout" 这样就可以达到两端控件分别左右对齐,中部控件填充剩余空间的效果。![](http://img.blog.csdn.net/20140901012200211)
上图效果的代码:
midlayout属性: android:layout_width="match_parent" android:layout_toLeftOf="@+id/rightlayout"
android:layout_toRightOf="@+id/leftlayout" 这样就可以达到两端控件分别左右对齐,中部控件填充剩余空间的效果。
上图效果的代码:
?xml version="1.0" encoding="utf-8"? RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="34dp" android:background="#FFFFFF" android:orientation="horizontal" LinearLayout android:id="@+id/choosetags_listview_item_leftlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" ImageView android:id="@+id/taglistview_item_ico" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:layout_marginBottom="2dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="2dp" android:contentDescription="@string/app_name" android:src="@drawable/tag_ico_movie" / /LinearLayout LinearLayout android:id="@+id/choosetags_listview_item_midlayout" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/choosetags_listview_item_rightlayout" android:layout_toRightOf="@+id/choosetags_listview_item_leftlayout" com.coolletter.util.MarqueeTextView android:id="@+id/taglistview_item_name" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_vertical" android:checkMark="?android:attr/textCheckMark" android:ellipsize="marquee" android:focusableInTouchMode="true" android:gravity="center_vertical" android:marqueeRepeatLimit="marquee_forever" android:paddingEnd="5dp" android:paddingStart="5dp" android:scrollHorizontally="true" android:singleLine="true" android:textColor="#000000" android:textSize="15dp" / /LinearLayout LinearLayout android:id="@+id/choosetags_listview_item_rightlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" TextView android:id="@+id/taglistview_item_newnum" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="253" android:textColor="#000000" /TextView /LinearLayout
图示:垂直布局方案: 1.外层放一个RealtiveLayout 2.内部三个控件分别装进3个LinearLayout中,id设为topayout,midlayout,bottomlayout toplayout属性:android:layout_width="wrap_content" bottomlayout属性:android:layout_width="wrap_content"
midlayout属性: android:layout_width="match_parent" android:layout_below="@+id/toplayout"
android:layout_above="@+id/bottomlayout"
布局:
![]()
代码:?xml version="1.0" encoding="utf-8"? RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#DCDCDC" android:orientation="vertical" LinearLayout android:id="@+id/letter_newtext_toplayout" android:layout_width="fill_parent" android:layout_height="45dp" android:layout_alignParentTop="true" android:background="#FFFAF0" android:orientation="horizontal" TextView android:id="@+id/letter_newtext_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:layout_weight="1" android:gravity="center_horizontal" android:text="Cancel" android:textColor="#000000" android:textSize="16dp" / TextView android:id="@+id/letter_newtext_submit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:layout_weight="1" android:gravity="center_horizontal" android:text="Submit" android:textColor="#000000" android:textSize="16dp" / /LinearLayout LinearLayout android:id="@+id/letter_newtext_mainlayout" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_above="@+id/letter_newtext_deliver" android:layout_below="@+id/letter_newtext_toplayout" android:orientation="vertical"当这种情况中间的控件是一个ScrollView时,也使用这种办法。就能实现ScrollView充满上下两个控件中间的区域。
android:id="@+id/letter_newtext_deliver" android:layout_above="@+id/letter_newtext__bottomlayout" android:layout_width="fill_parent" android:layout_height="0.5dp" android:background="#00BFFF" / LinearLayout android:id="@+id/letter_newtext__bottomlayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:gravity="bottom" android:orientation="horizontal" ImageView android:id="@+id/letter_newtext_ico_tag" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginLeft="5dp" android:background="@drawable/letter_new_ico_maintag" / TextView android:id="@+id/letter_newtext_tag_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:textColor="#000000" android:textSize="15dp" / /LinearLayout
/RelativeLayoutReference:
http://blog.csdn.net/geeklei/article/details/38968735
Android屏蔽隐藏系统自带输入键盘 若是Activity,在AndroidMainfest.xml配置Activity属性:android:windowSoftInputMode= stateAlwaysHidden|...
主要要使用一个正则过滤即可实现: String regular = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 mXEditText.
小菜最近因工作需要做一个支付金额对话框的小模块,技术很浅显,遇到几个小坑,分享给大家~
小菜遇到的坑之一: 其他页面中获取到的金额需要保存两位小数,本来我打算直接用 String 转为 double 类型,但是遇到保存精度问题(String=19.
相关文章
- [Android]calabash-android再深入
- 【Android】 Android中Log调试详解
- [Android Pro] android Flag介绍
- Android开发之adb无法连接
- 记写 android 微信登录的demo历程
- Android开发学习---使用Intelij idea 13.1 进行android 开发
- android 5.0新特性学习--CardView
- 《android开发艺术探索》读书笔记(十一)--Android的线程和线程池
- macos安装android studio(Android Studio 2021.1.1)
- 理解Android系统中强指针的实现
- Android Input输入系统之一:KeyEvent事件监听
- android开发分享Android中外接键盘的检测的实现
- 【Android笔记78】Android之图片加载库Glide(过渡、变换效果)
- 【Android笔记67】Android之动态申请访问权限(工具类封装)
- Android的finish
- Android Studio的Logcat窗口在哪
- Android 10.0 SystemUI 仿华为充电动画
- 【Android Gradle 插件】build.gradle 中的 android 配置 ( 配置项 | compileSdkVersion 配置 | buildToolsVersion 配置 )
- 【Android 逆向】代码调试器开发 ( ptrace 函数 | 读取进程内存数据 )
- 【Android】android图片轮播
- Android通过命令连接wifi(解决usb不能用+无屏幕情况)(八十二)
- Android Studio下“Error:Could not find com.android.tools.build:gradle:2.2.1”的解决方法
- Android权限 uses-permission
- 【Android自动化】AccessibilityService实战-微信僵尸好友检测