我粗略地了解了这些目录的用途,但我对这个概念并不是很清楚,而且我有一些具体的问题.
例如,每个目录的目标DPI是多少?创建资产时,它应该是该目标DPI还是应该是更正常的72dpi屏幕DPI?如果您要定位多个设备,是否适合将PNG放入drawable中,或者您是否应始终为特定屏幕量身定制多个版本?
谢谢.
我正在为Android编写实时游戏,在查看SDK中提供的示例中的一些代码后,我很困惑何时应该在我的游戏中使用Bitmap或Drawable作为我的精灵.
有什么不同?哪一个更好(更快)的精灵,哪一个更好的静态背景?
mobile android android-2.2-froyo android-drawable android-bitmap
我有:
<stroke android:width="1px" android:color="#A6ACB1"/>
Run Code Online (Sandbox Code Playgroud)
我想从元素的底部(例如)中删除此边框.可能吗?(Eclipse仅建议我:color,width,dashWidth和dashGap).
我已经看过Timely应用程序,它让我用他们的动画背景催眠,它有浮动的气泡和
你能告诉我怎样才能做到这一点,我已经尝试过使用AnimatorSet的AnimationDrawable和ValueAnimator,但这似乎与使用的及时应用程序有所不同
我在Nexus 5上测试Android L预览.我的应用程序出了问题.
我有一些背景设置的TextViews:
android:background="@drawable/rounded_textview"
Run Code Online (Sandbox Code Playgroud)
而"rounded_textview"就是形状.它在<= API19下工作得很好.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="3dp">
<solid android:color="#999999"/>
<corners
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
在Android L开发人员预览背景被忽略.我的所有TextView都是透明的.知道我做错了什么吗?
我以编程方式创建每个视图之间带有水平线的文本视图.使用以编程方式创建的drawable.
问题是,不透明度从光线开始,逐渐增加每条线.
我已经记录了所提供的两种方法中所有点的可绘制,绘画,图像视图和线性布局的不透明度(getAlpha()),并且从drawable中它总是255和视图1.0.我不明白为什么它不是表现得好像这样.我也试过设置Alpha,它没有任何区别.
为什么这样做,我该如何解决?
XML:
<LinearLayout android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" .../>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="PaintDashedLines"
android:text="Press Me"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Java的:
static int tvCount = 0;
public void PaintDashedLines(View v) {
LinearLayout ll = (LinearLayout) findViewById(R.id.main);
TextView tv = new TextView(MainActivity.this);
tv.setGravity(Gravity.CENTER);
tv.setTextSize(25);
tv.setPadding(0, 5, 0, 5);
ll.addView(tv);
tv.setText("TextView " + tvCount);
ImageView divider = new ImageView(MainActivity.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ll.getWidth(), 2);
lp.setMargins(0, 5, 0, 5);
divider.setLayoutParams(lp);
divider.setBackground(CreateDashedLined());
ll.addView(divider);
tvCount++;
}
public static Drawable CreateDashedLined() {
ShapeDrawable sd = new …Run Code Online (Sandbox Code Playgroud) 在android中我已经阅读了一些关于drawable如何共享一个常量状态的文章.因此,如果您对drawable进行更改,则会影响所有相同的位图.例如,假设你有一个明星可绘制的列表.更改一个alpha将改变所有星形drawables alpha.但是您可以使用mutate来获取没有共享状态的drawable副本.
我正在阅读的文章就在这里
现在我的问题:
android中以下两个调用之间有什么区别:
Drawable clone = drawable.getConstantState().newDrawable();
// vs
Drawable clone = (Drawable) drawable.getDrawable().mutate();
Run Code Online (Sandbox Code Playgroud)
对我来说,他们都克隆了一个drawable,因为他们都返回了一个没有共享状态的drawable.我错过了什么吗?
我有几个按钮,我需要一个椭圆形的边框.
所以我在capsule_border.xml中有这个
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="9999dp"/>
<stroke
android:width="1px"
android:color="@color/border_gray" />
</shape>
Run Code Online (Sandbox Code Playgroud)
我会android:background="@drawable/capsule_border.xml在需要它的地方使用它.
现在,我希望有一个按钮,以获得这个椭圆形边框,但也有一个android:background="?selectableItemBackground"视觉反馈.
我尝试使用带有selectableItembackground的父布局和带有capsule_border的按钮.但似乎突出显示的可点击区域是整个方块.而不仅仅是胶囊边界内的区域.
有没有我可以做到这一点,以便selectableItemBackground不高度视图的整个矩形,但只在我绘制的边框内?
android android-layout android-view android-selector android-drawable
对于android studio项目,我在"values"文件夹中找到了一个名为"drawables.xml"的文件
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
</resources>
Run Code Online (Sandbox Code Playgroud)
这个文件的目的是什么?为什么它会创建另一个对现有drawable的引用,为什么不使用"@android:drawable/ic_menu_camera"?
In icon.svg
ERROR@ line 9 <text> is not supported
ERROR@ line 10 <tspan> is not supported
Run Code Online (Sandbox Code Playgroud)
如何导出这种类型的svg矢量drawable?这甚至可能吗?或者我应该寻找新的svg?
android ×10
android-drawable ×10
android-xml ×2
alpha ×1
android-view ×1
animation ×1
background ×1
border ×1
effects ×1
java ×1
mobile ×1
paint ×1
svg ×1