我正在开发一个功能,从Web服务器下载图像,将其显示在屏幕上,如果用户希望保留图像,请将其保存在某个文件夹中的SD卡上.是否有一种简单的方法来获取位图并将其保存到我选择的文件夹中的SD卡?
我的问题是我可以下载图像,将其作为位图显示在屏幕上.我能够找到将图像保存到特定文件夹的唯一方法是使用FileOutputStream,但这需要一个字节数组.我不确定如何从Bitmap转换(如果这是正确的方法)到字节数组,所以我可以使用FileOutputStream来写入数据.
我有另一个选择是使用MediaStore:
MediaStore.Images.Media.insertImage(getContentResolver(), bm,
barcodeNumber + ".jpg Card Image", barcodeNumber + ".jpg Card Image");
Run Code Online (Sandbox Code Playgroud)
哪个可以保存到SD卡,但不允许您自定义文件夹.
我最近一直在开发一个Android应用程序,我需要为标签栏设置自定义布局和尺寸.我到目前为止的方式是使用Jake Wharton的ActionBarSherlock库来支持pre-HoneyComb Android版本,并通过将样式应用于我编辑actionBarSize样式项的应用程序.
现在,我一直在测试Galaxy S3上的应用程序(上面有Jellybean),并且标签栏高度不再根据actionBarSize值变化.
所以我开始查看JellyBean的代码,我在ActionBarPolicy课堂上找到了这个方法:
public int getTabContainerHeight() {
TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar,
com.android.internal.R.attr.actionBarStyle, 0);
int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
Resources r = mContext.getResources();
if (!hasEmbeddedTabs()) {
// Stacked tabs; limit the height
height = Math.min(height,
r.getDimensionPixelSize(R.dimen.action_bar_stacked_max_height));
}
a.recycle();
return height;
}
Run Code Online (Sandbox Code Playgroud)
从我在这个方法中收集的内容来看,当应用程序处于纵向模式时,似乎JellyBean通过将标签栏高度设置为"action_bar_stacked_max_height"维度值(在4.1的/values/dimen.xml文件中为48dp)来限制TabBar的高度),即使我已设置动作栏高度actionBarSize.
我已经尝试覆盖这个维度值,通过在我自己的dimen.xml文件中将其设置为我自己的值,但我没有运气.它没用.
我的问题:
你们知道我可以覆盖"action_bar_stacked_max_height"维度值的方法吗?
先感谢您!
tabs android actionbarsherlock android-actionbar android-4.2-jelly-bean
我试着使用这段代码
<item
android:id="@+id/male_button"
android:layout_width="46dp"
android:layout_height="56dp"
android:layout_gravity="right"
android:icon="@drawable/icon_male"
android:showAsAction="always"
android:title="i"/>
<item
android:id="@+id/female_button"
android:layout_width="46dp"
android:layout_height="56dp"
android:layout_gravity="right"
android:icon="@drawable/icon_female"
android:showAsAction="always"
android:title="i"/>
Run Code Online (Sandbox Code Playgroud)
我改变了android:layout_width ="46dp"到android:layout_width ="30dp"但我仍然有相同的大小所需的图像是

而我现在有这个

如何将图标更改为第一张图片?
Android 4.2中的操作栏图标大小是否已更改?我有一个120x48px HDPI图标,在Android 4.1及更低版本中完美呈现.它仍然是.
但是,在任何4.2设备上,它都被压缩到可以看到的48x48px.或类似的东西; 这绝对是一个广场.
有任何想法吗 ?谢谢 !
我想有一个更大的行动吧.所以我改变了样式中的操作栏大小,现在我正在寻找更改图标大小并将文本放大.
这是我的风格:
<!-- Application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textSize">22sp</item>
<item name="android:actionBarSize">100dp</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="android:style/Widget.ActionButton">
<item name="android:layout_width">fill_parent</item>
</style>
<style name="MyActionBarTabText" parent="android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">25dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的actionBar菜单(menu.xml):
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/app_setting"
android:title="@string/app_setting"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_setting"
android:showAsAction="ifRoom" />
</menu>
Run Code Online (Sandbox Code Playgroud)
在主要课程中:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
此外,我尝试了几个问题,但我无法使其发挥作用.