我正在尝试制作Android布局:垂直LinearLayout中的3个组件.中心组件是ScrollView
包含a的组件TextView
.当TextView
包含大量文本(超过屏幕上可以容纳的文本)时,ScrollView
会一直增长到屏幕底部,显示滚动条,并将最后一个组件(内部LinearLayout
有一个)推Button
离屏幕.
如果内的文本TextView
内的ScrollView
足够短,在屏幕底部的按钮被完全定位.
我想要实现的布局是:
我编写的布局的XML是:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:text="Title />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:textColor="#FFFFFF"
android:background="#444444"
android:padding="10dip" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/login_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="@string/next_button"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试找到与Java枚举类型或"公共静态最终"对象等效的Objective-C,例如:
public enum MyEnum {
private String str;
private int val;
FOO( "foo string", 42 ),
BAR( "bar string", 1337 );
MyEnum( String str, int val ) {
this.str = str;
this.val = val;
}
}
Run Code Online (Sandbox Code Playgroud)
要么,
public static final MyObject FOO = new MyObject( "foo", 42 );
Run Code Online (Sandbox Code Playgroud)
我需要创建常量(当然)的常量,并且可以在任何导入相关.h文件或全局的地方访问.我试过以下但没有成功:
foo.h中:
static MyEnumClass* FOO;
Run Code Online (Sandbox Code Playgroud)
Foo.m:
+ (void)initialize {
FOO = [[MyEnumClass alloc] initWithStr:@"foo string" andInt:42];
}
Run Code Online (Sandbox Code Playgroud)
当我这样做并尝试使用FOO
常量时,它str
和val
变量中没有值.我通过使用实际上被调用的NSLog
调用来验证initialize
.
此外,即使我FOO
在代码的测试块中引用变量,Xcode 也会使用注释突出显示上面显示的.h文件中的行 …