我想将一些视图从任何位置移动到屏幕中心并平行缩放.如果这太复杂,顺序翻译和缩放也是可以接受的.但我无法实现.我认为这是枢轴点的问题.但抱歉,我没有找到解决办法.请帮忙.也许这对开发游戏的人来说很容易,我什么也没做.
以下是我的代码:
private void moveViewToScreenCenter( final View view ){
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( dm );
int statusBarOffset = dm.heightPixels - rootLayout.getMeasuredHeight();
int originalPos[] = new int[2];
view.getLocationOnScreen( originalPos );
int xDelta = (dm.widthPixels - view.getMeasuredWidth())/2 - originalPos[0];
int yDelta = (dm.heightPixels - view.getMeasuredHeight())/2 + statusBarOffset - originalPos[1];
AnimationSet animSet = new AnimationSet(true);
animSet.setFillAfter(true);
animSet.setDuration(1000);
animSet.setInterpolator(new BounceInterpolator());
TranslateAnimation translate = new TranslateAnimation( 0, xDelta , 0, yDelta);
animSet.addAnimation(translate);
ScaleAnimation scale = new ScaleAnimation(1f, …Run Code Online (Sandbox Code Playgroud) 有没有办法改变ActionBar标题和副标题的大小/颜色?
我正在使用ActionBarSherlock来桥接较低版本和更高版本.ActionBarSherlock提供了在SherlockActionBarCompat中自定义文本样式的方法,但似乎没有办法在SherlockActionBarNative中创建它.
编辑: 由杰克添加并由作者删除
编辑: 关闭解决方案:
<style name="resizeableTitleStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">@dimen/action_bar_title_text_size</item>
</style>
<style name="Theme.ResizeableActionBar" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/resizeableActionBarStyle</item>
<item name="android:actionBarStyle">@style/resizeableActionBarStyle</item>
<item name="actionBarSize">60dp</item>
<item name="android:actionBarSize">60dp</item>
</style>
<style name="resizeableActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="titleTextStyle">@style/resizeableTitleStyle</item>
<item name="android:titleTextStyle">@style/resizeableTitleStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)
感谢ABS的作者Jake的帮助.
现在几乎完成了,除了只能通过相当多的试验估算actionBarSize的近似绝对尺寸(我的应用程序为60dp); wrap_content导致API2.2扩展整个屏幕,并在解析xml时抛出API4.2.2异常.
另外:
当actionBarSize设置为0dp时,输出为(http://i.stack.imgur.com/xX4E1.png,低信誉直接在此处发布图像):左侧的API2.2,操作栏占用整个屏幕没有内容,API4.2.2在右边,内容没有动作栏.
当设置为wrap_content时,API2.2的输出相同,并抛出异常:引起:java.lang.UnsupportedOperationException:无法转换为维度:type = 0x10