我在通常的strings.xml资源文件中定义了字符串,如下所示:
<string name="hello_world"> HELLO</string>
Run Code Online (Sandbox Code Playgroud)
是否可以定义格式字符串,如下所示
result_str = String.format("Amount: %.2f for %d days ", var1, var2);
Run Code Online (Sandbox Code Playgroud)
在strings.xml资源文件中?
我试图逃避特殊字符,但它不起作用.
我在哪里可以找到InputType可以拥有的值?
我知道http://developer.android.com/reference/android/text/InputType.html,但是布局xml文件中的值应如何?
有没有直接测量文字高度的方法?我现在这样做的方法是使用Paint measureText()来获取宽度,然后通过试验和错误找到一个值来获得近似高度.我也一直在搞乱FontMetrics,但所有这些似乎都是近似的方法.
我正在尝试扩展不同分辨率的东西.我可以做到,但我最终得到了令人难以置信的冗长代码,并通过大量计算来确定相对大小.我讨厌它!一定有更好的方法.
我开始搜索时想知道如何与iOS中的其他应用分享.我发现有两个重要的方法
UIActivityViewControllerUIDocumentInteractionController在这个SO答案中比较了这些和其他方法.
通常当我学习一个新概念时,我希望看到一个让我入门的基本例子.一旦我得到基本的设置,我可以稍后修改它.
有很多与之相关的问题UIActivityViewController,但我找不到任何只是要求一个简单的例子.由于我刚刚学会了如何做到这一点,我将在下面提供我自己的答案.随意添加一个更好的(或Objective-C版本).
我想为我正在创建的Android应用程序使用自定义字体.
我可以从Code中单独更改每个对象的字体,但我有数百个.
所以,
所以标题说明了一切.我的内部出现了编译错误onClick.
这是代码.
public class fieldsActivity extends Activity {
Button addSiteButton;
Button cancelButton;
Button signInButton;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// to create a custom title bar for activity window
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.fields);
// use custom layout title bar
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.topbar);
Pager adapter = new Pager();
ViewPager mPager = (ViewPager) findViewById(R.id.fieldspager);
mPager.setAdapter(adapter);
mPager.setCurrentItem(1);
addSiteButton = (Button) findViewById(R.id.addSiteButton);
addSiteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPager.setCurrentItem(2, true); …Run Code Online (Sandbox Code Playgroud) 我创建了一个按钮,我想为该按钮添加涟漪效果!
我创建了一个按钮bg XML文件:(bg_btn.xml)
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFFFF" android:endColor="#00FF00" android:angle="270" />
<corners android:radius="3dp" />
<stroke android:width="5px" android:color="#000000" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这是我的涟漪效应文件:(ripple_bg.xml)
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="#f816a463"
tools:targetApi="lollipop">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#f816a463" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
这是我想要添加涟漪效果的按钮:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginTop="173dp"
android:textColor="#fff"
android:background="@drawable/ripple_bg"
android:clickable="true" />
Run Code Online (Sandbox Code Playgroud)
但添加涟漪效果后按钮背景是透明的,只有在点击时才会显示按钮,如下所示:
点击之前
点击

但我需要按钮背景颜色和涟漪效果,我在Stack Overflow的不同博客中发现了一些此代码,但它仍然无效!
我正在尝试制作一个从屏幕中间以白色发出的渐变,并在向屏幕边缘移动时变为黑色.
当我制作像这样的"普通"渐变时,我一直在尝试不同的形状:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#E9E9E9" android:endColor="#D4D4D4"
android:angle="270"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
当使用"椭圆形"形状时,我至少得到了圆形,但没有渐变效果.我怎么能做到这一点?'
我创建了一个自定义视图(在此处找到),其中包含enum类型的declare-styleable属性.在xml中,我现在可以为自定义属性选择一个枚举条目.现在我想创建一个以编程方式设置此值的方法,但我无法访问枚举.
attr.xml
<declare-styleable name="IconView">
<attr name="icon" format="enum">
<enum name="enum_name_one" value="0"/>
....
<enum name="enum_name_n" value="666"/>
</attr>
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
layout.xml
<com.xyz.views.IconView
android:id="@+id/heart_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:icon="enum_name_x"/>
Run Code Online (Sandbox Code Playgroud)
我需要的是:mCustomView.setIcon(R.id.enum_name_x);
但是我找不到枚举,或者我甚至不知道如何获得枚举或枚举的名称.
我正在寻找iOS 7的iOS字体列表.我在Apple的开发者网站上找到了这个列表,我只是想知道是否有人知道一个可视列表,其中每个字体名称都是在其字体中输入的.我之前看过一两个,但我见过的最新版本是针对iOS 5的,从那时起又添加了更多.