我正在使用 Yuri Kanivets's WheelView control我发现它没有填充父 View ,即使布局 XML 指定它这样做。
这是我的意思的图像:
这是布局 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000">
<LinearLayout
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="@drawable/picker_bar">
<Button
android:id="@+id/repeatButton"
android:textColor="#FFF"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/picker_button_selected"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginLeft="7dp"
android:gravity="center"
android:textSize="16sp"
android:text="Repeat"/>
<Button
android:id="@+id/DelayButton"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/picker_button_unselected"
android:paddingTop="8dp"
android:textColor="#FFF"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_marginLeft="10dp"
android:gravity="center"
android:textSize="16sp"
android:text="Delay"/>
<Button
android:id="@+id/doneButton"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/picker_button_unselected"
android:textColor="#FFF"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:gravity="center"
android:textSize="16sp"
android:text="Done"/>
</LinearLayout>
<include layout="@layout/repeat_view"/>
<include layout="@layout/delay_view"/>
</LinearLayout>
</RelativeLayout>
这是重复/延迟 View XML(它们几乎相同):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wheelRepeat"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/layout_bg"
android:layout_width="fill_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:orientation="horizontal">
<desiderata.ihunt.resources.WheelView
android:id="@+id/activeRepeat"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
<desiderata.ihunt.resources.WheelView
android:id="@+id/minsRepeat"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"/>
<desiderata.ihunt.resources.WheelView
android:id="@+id/secsRepeat"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"/>
</LinearLayout>
</LinearLayout>
这是我添加 View 的方式:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
...
我查看了 WheelView 源代码,但不清楚在哪里设置了整个控件的宽度以及滚轮控件是否以某种方式也控制了父布局的宽度。
这是在最新的 SDK 上运行。有什么明显的东西是我遗漏的吗?
最佳答案
包含三个 desiderata.ihunt.resources.WheelView 的 LinearLayout 具有 android:layout_width="fill_parent",但 WheelView 本身有:
android:layout_height="wrap_content"
android:layout_width="wrap_content"
话虽这么说,如果我正确理解问题的意思是,如果三个轮子的宽度小于 parent 的宽度(在本例中为 LinearLayout 其中包含三个 desiderata.ihunt.resources.WheelView) - 然后你必须拉伸(stretch)轮子或用纯色填充 LinearLayout(例如黑色) 以隐藏其背后的内容。
关于android - WheelView 未填充父项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202218/
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我有一个驼峰式字符串,例如:JustAString。我想按照以下规则形成长度为4的字符串:抓取所有大写字母;如果超过4个大写字母,只保留前4个;如果少于4个大写字母,则将最后大写字母后的字母大写并添加字母,直到长度变为4。以下是可能发生的3种情况:ThisIsMyString将产生TIMS(大写字母);ThisIsOneVeryLongString将产生TIOV(前4个大写字母);MyString将生成MSTR(大写字母+tr大写)。我设法用这个片段解决了前两种情况:str.scan(/[A-Z]/).first(4).join但是,我不太确定如何最好地修改上面的代码片段以处理最后一种
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我正在尝试解决http://projecteuler.net/problem=1.我想创建一个方法,它接受一个整数,然后创建一个包含它前面的所有整数的数组,并将整数本身作为数组中的值。以下是我目前所拥有的。代码不起作用。defmake_array(num)numbers=Array.newnumcount=1numbers.eachdo|number|numbers 最佳答案 (1..num).to_a是您在Ruby中需要做的全部。1..num将创建一个Range对象,以1开始并以任意值num结束是。Range对象有to_a方法通过
如果我想要“00001”而不是“1”,除了我自己写填零方法之外,有没有内置的方法可以帮助我为整数填零? 最佳答案 puts"%05d"%1#00001参见:String::%,Kernel::sprintf这是正在发生的事情。%左侧的"%05d"是C风格的格式说明符。%右边的变量就是要格式化的东西。格式说明符可以像这样解码:%-格式说明符的开头0-用前导零填充5-长度为5个字符d-被格式化的是一个整数如果你要格式化多个东西,你会把它们放在一个数组中:"%d-%s"%[1,"One"]#=>1-one
使用RubyonRails,我使用给定的增量(例如每30分钟)用时间填充“选择”。目前我正在YAML文件中写出所有的可能性,但我觉得有一种更巧妙的方法。我想我想提供一个开始时间、一个结束时间、一个增量,并且目前只提供一个名为“关闭”的选项(想想“business_hours”)。所以,我的选择可能会显示:'Closed'5:00am5:30am6:00am...[allthewayto]...11:30pm谁能想出更好的方法,或者只是将它们全部“拼写”出来的最佳方法? 最佳答案 此答案基于@emh的答案。defcreate_hour
我有一个表,我们称它为MyTable。它是Postgresql数据库的一部分。MyTable中有很多条目,比方说超过一百万。我想向该表中添加一个字段,我们将其命名为MyNewField。它由ActiveRecord迁移添加。此字段没有默认值且不可为空。结果,在它的迁移类中将是这样的:classAddMyFieldToMyTable但是,它会触发一个错误(PG::NotNullViolation),因为该表已经包含行,所有这些行的MyField都设置为NULL。我想做的是:添加没有默认值且可空设置为false的行(不触发PG::NotNullViolation)。然后,将另一个表中的值插
我正在尝试创建一个函数来完成以下哈希中的小时序列。{name:"cardio",data:[["06:00",999],["09:00",154],["10:00",1059],["11:00",90]]}它应该在字段数据中创建所有缺失值["07:00",0],["08:00",0],["12:00",0],["13:00",0]...["23:00",0]预期结果:{name:"cardio",data:[["06:00",999],["07:00",0],["08:00",0],["09:00",154],["10:00",1059],["11:00",90]],["12:00",
用户可以输入自定义:action或选择特色:action:Orchooseafeaturedchallenge:如果用户选择特色:action,新的挑战/_form会预先填充他选择的:action,但现在我想把它带到在您的帮助下更上一层楼!Challenge:DoOn:DoFor:如何预填充特色挑战的其他属性,例如“DoFor”或“DoOn”?例如,如果用户选择特色:action:'RunaMile那么我会用RunaMile预填充表单>,周一、周三、周五,30天。 最佳答案 您可以将simple_form与reform一起使用。Re
首先,我是Rails的新手,如果有任何我不理解的地方,请见谅。我想知道如何通过API获取数据来填充模型。上下文:我正在使用带有omniauth/devise的OAuth2身份验证。在我的用户Controller客户端(与提供者相对)中,我获取了所有至少登录一次的用户就是这个“客户端应用程序”,我想显示它们。显然,每当新用户登录到客户端应用程序时,我不会将他的所有信息存储在客户端数据库中以避免重复。我存储的只是user_id及其访问token。因此,我想在获取所有用户数据后,我可以将它们填充到用户模型,然后再将其传递给View。做这样的事情最好的方法是什么?我正在研究命名范围,但我不清楚