好的,首先,我搜索了所有的互联网,但没有人有类似的问题.所以,我想要的只有3个textViews,底部与屏幕对齐,宽度相同.这是一个代表我想要的图像:
这是我的代码:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:text="@string/help_1"
android:layout_weight="0.33"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/mynicebg1"
android:layout_gravity="bottom"/>
<TextView
android:text="@string/help_2"
android:layout_weight="0.33"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/mynicebg2"
android:layout_gravity="bottom"/>
<TextView
android:text="@string/help_3"
android:layout_weight="0.33"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/mynicebg3"
android:layout_gravity="bottom"/>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
好吧,当3个textView具有相同的高度时,它可以工作,但是当它们的大小不同时,我得到以下结果:
另一个奇怪的行为是,当我将最大文本的layout_gravity设置为"center-vertical"时,我得到以下结果:
显然,我疯了,尝试了另一种中心垂直组合,但最初没有任何效果:
那么,有关如何解决这个问题的任何提示?
在自定义视图上使用9补丁图像资源的正确方法是什么?
我这样做:
background = BitmapFactory.decodeResource(getResources(), R.drawable.fundo_bookshelf);
canvas.drawBitmap(background, null, new Rect(0, y, width, y+backgroundHeight), null);
Run Code Online (Sandbox Code Playgroud)
fundo_bookshelf是一个适当的9补丁图像,保存为fundo_bookshelf.9.png,如下所示:
但是当使用drawBitmap时,整个图像被拉伸,而不是只有顶部带有黑色像素的部分,如此截图所示:
好的,这很简单:我有一个FileObserver类来观察带有音乐的文件夹.所以我实现了onEvent和所有这些东西,但当我使用文件管理器移动或粘贴该文件夹上的文件时,而不是获取FileObserver.MOVED_TO或FileObserver.CREATE,我得到的奇怪事件的数字如1073741656,未记录在:http: //developer.android.com/reference/android/os/FileObserver.html
那么如何获取删除,移动,创建和粘贴等特定事件?
[编辑]这是代码:
private class MusicsFileObserver extends FileObserver {
public MusicsFileObserver(String root) {
super(root);
if (!root.endsWith(File.separator)) {
root += File.separator;
}
}
@SuppressWarnings("unused")
public void close() {
super.finalize();
}
public void onEvent(final int event, String path) {
//here is the problem, if you see the documentation, when a file is moved
//to this directory, event should be equal to FileObserver.MOVED_TO,
//a constant value of 128. But when debugging, instead of entering here one time
//with event == …
Run Code Online (Sandbox Code Playgroud) 我在API中看到的唯一样式选项是:
是否有可能以某种方式将按钮涂成另一种颜色?我们的设计师真的不喜欢默认的蓝色按钮
我想为我的项目创建一个这样的方法:
func print(obj: AnyObject) {
if let rect = obj as? CGRect {
println(NSStringFromCGRect(rect))
}
else if let size = obj as? CGSize {
println(NSStringFromCGSize(size))
}
//...
}
Run Code Online (Sandbox Code Playgroud)
但我不能因为CGRect
和CGSize
是struct
S和不符合AnyObject
protocol
.那么,关于如何做到这一点的任何想法?
我正在执行以下查询:
realm.objects('Maker').filtered("categories CONTAINS $0", categoryObject)
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
Only 'equal' and 'not equal' operators are supported for object comparison
Run Code Online (Sandbox Code Playgroud)
这是我的架构:
{
name: 'MakerOption',
primaryKey: 'serverId',
properties: {
serverId: 'int',
name: 'string',
categories: {type: 'list', objectType: 'Category'},
}
{
name: 'Category',
primaryKey: 'serverId',
properties: {
serverId: 'int',
name: 'string'
}
Run Code Online (Sandbox Code Playgroud)
有关此主题的文档很少。是否有其他方法可以做到这一点?
android ×3
ios ×2
3dtouch ×1
any ×1
anyobject ×1
cocoa-touch ×1
react-native ×1
realm ×1
struct ×1
swift ×1