Tag: android layout

禁用从纵向到横向的默认animation

我有一个应用程序,可以在横向或纵向上运行几个“正常”的活动。 他们是专为和大多用于肖像。 这个应用程序有一个单一的活动,使用相机,并locking在风景。 我'模拟'这个活动是通过旋转90度的图像和文字的肖像,所以它看起来像其余的活动。 在某些设备上,如三星Galaxy Tab 7和Galaxy S3, 从正常肖像活动转到相机横向活动并返回时,会显示一个旋转animation 。 这对于用户来说是令人困惑的,因为景观活动模拟在肖像上。 有没有办法去除这个旋转animation ? 理想情况下,我想更改为默认肖像肖像animation,但只是删除旋转animation就足够了。 我试过了 overridePendingTransition(0, 0); 该方法的其他变体没有成功。 [添加] 根据@igalarzab,@Georg和@Joe的build议,我已经完成了这个(仍然没有运气): 向Manifest添加了android:configChanges =“orientation | screenSize” 添加onConfigurationChanged 创build了一个虚拟animation,它什么也不做,并添加overridePendingTransition(R.anim.nothing,R.anim.nothing); 我有这些结果: onConfigurationChanged仅在旋转相同的Activity(纵向上的活动A – 横向上的活动A)时被调用。 但是从肖像上的活动A到横向上的活动B都不会被调用 这防止了活动在旋转时重新启动,但它并没有删除旋转animation(在Galaxy S3,Galaxy Nexus,Galaxy Tab 7.0和Galaxy Tab 10.1上testing) overridePendingTransition(R.anim.nothing,R.anim.nothing); 删除了正常的转换(纵向 – >纵向和横向 – >横向),但没有移除旋转animation(纵向 – >横向,反之亦然)。 我已经上传了一个显示我想要禁用的animation的video。 将相机活动(locking到风景)更改为其他活动,同时将手机保持在人像上时会发生这种情况:

MotionEvent.getRawX和MotionEvent.getX之间的区别

我想知道android中的MotionEvent.getRawX和MotionEvent.getX之间的区别是数字,而另一个是浮动?这两种types都需要什么?

如何使用AppCompat v.7显示和隐藏ActionBar

我有一个简单的应用程序,显示文字。 该应用程序开始与一个主屏幕上有几个选项(例如一个信息button,导致有关应用程序的信息,浏览button,使用户可以看到所有可以显示的文本片段)。 主button导致另一个显示文本的屏幕。 通过左右滑动,他可以看到不同的文字段落。 这是应用程序的主要目的。 目前我有一个ActionBar实现。 我的MainActivity.Java扩展AppCompatActivity。 应用程序中的一切都在这个活动中。 现在,我想让ActionBar仅在“显示”模式下显示,而不是在启动屏幕或“信息”/“浏览”模式下显示。 是否有可能在应用程序的一部分中有一个ActionBar,而在应用程序的另一部分没有 ActionBar? (并保持在同一个活动?) 我一直在试图完成这个无用的。 如果这是可能的,我应该接下来尝试什么? 到目前为止,我已经尝试了以下内容: 1)创build这个主题 <style name="Theme.AppCompat.NoActionBar" parent="Theme.AppCompat.Light"> <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> </style> 并将其应用于MainActivity … <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/Theme.AppCompat.NoActionBar" > 这样做之后,ActionBar仍然在那里。 (这来自这个SOpost( android:windowNoTitle不会隐藏与appcompat-v7 21.0.0操作栏 ) 2)另一个尝试是将此添加到onCreate。 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getActionBar().hide(); setContentView(R.layout.activity_main); 这是来自于研究这个SOpost:( 如何在活动创build之前隐藏操作栏,然后再显示它? ) 有什么build议么?

如何closuresDatePicker中的CalendarView?

在我的设置屏幕上,我有一个dateselect器小部件。 在Eclipse中的devise器中,它显示为我想要的(DMY的3个旋转器),但是当我在我的设备上进行testing时,我看到一个相当奇怪的视图,左边是一个侧面旋钮,右边是一个日历。 (!)之前从来没有见过,但做一些研究,我想我看到“CalendarView”。 我发现我应该能够将“calendarViewShown”属性设置为false,但是我的XML会抛出一个错误。 我在这里发现了另一个问题,build议API级别是责备(我minSDKLevel是7,但我的目标是11,所以我可以得到操作栏button,而不是旧菜单)。 所以我想我会尝试在代码中设置它: int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= 11) minDateSelector.setCalendarViewShown = false; 但是,再次,失败setCalendarViewShown找不到。 但是这里的文档说它应该存在。 有任何想法吗?!

Android:以图片为中心

我有一个线性布局和图像… <?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"> <ImageView android:layout_width="wrap_content" android:id="@+id/imageView1" android:src="@drawable/icon" android:layout_height="wrap_content" android:scaleType="center"></ImageView> </LinearLayout> 我如何dynamic调整图像的中心位置,使其在所有设备的屏幕中间出现?

奇怪的xml错误:错误行结束

自1周前以来,我还没有使用过Eclipse。 今天我开始了,我注意到它缓慢加载。 当它启动时,它提示: http://tinypic.com?ref=2zpk1g2&quot; target =“_ blank”> <img src =“ http://i48.tinypic.com/2zpk1g2.png&quot ; border=”0“alt =”图片和video由TinyPic托pipe“> </a>”> 我认为,也许Eclipse已经更新了Android的东西,所以我更新到最新的ADT。 现在我有同样的错误,但我有一个额外的大错误,我不知道是否因为以前的错误。 我已经尝试了一下xml层在许多设备中的外观。 我已经尝试了2层,现在该程序不编译,因为它说: 错误的行结尾:find回车符(\ r)而没有对应的换行符(\ n) 一个XML的错误是在这一行: android:layout_height="wrap_content"> 另一个在: android:orientation="horizontal"> 跆拳道已经发生? 我没有改变任何东西,也没有保存,1周前一切都很好。

如何分组数据库中的项目并显示它们 – Android

我有Android应用程序中的收据和日志模型。 收据有许多日志。 我通过sortID和grade来查询group_by日志。 //recieve RecepitID and query to group logs final long forwardedId = (long) getIntent().getExtras().get(String.valueOf("recepitID")); List<Logs> logsList = new Select().from(Logs.class).where("Receipt = " + forwardedId).groupBy("SortID, Grade").execute(); 这个分组工作正常。 接下来是问题。 我需要这样的输出(红色部分): 但是我明白这一点: 这是我如何做到这一点的代码的一部分。 public class LogsRecapitulation extends AppCompatActivity { private ListView mainListView; private BaseAdapter listAdapter; private TextView logsCount; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recapitulation_listview); mainListView […]

FragmentTabHostgraphics布局不呈现

简单的android.support.v4.app.FragmentTabHost的graphics布局不会在Eclipse或Android Studio中呈现。 我得到的控制台错误始终如一: Exception raised during rendering: No tab known for tag null 我正在使用最基本的XML文件: <android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TabWidget android:id="@android:id/tabs" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0"/> <FrameLayout android:id="@+id/realtabcontent" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> </LinearLayout> </android.support.v4.app.FragmentTabHost> 但同样的错误发生。 我只是想添加更多的视图上方或下方的标签小部件和框架布局。 我不太在乎看到标签的内容; 我只想看看我的布局的其余部分 – 但问题是,当一个 android.support.v4.app.FragmentTabHost 驻留在布局 时,没有其他视图呈现 。 我已阅读并试图解决这个问题的答案: Android:在FragmentTabHost底部的标签 但我不认为这是我的问题; 我不打算把TabWidget放在底部。 […]

Android支持库v7:检索项目的父项时出错

我正在尝试构buildAndroid支持库v7示例。 为此,我通过Eclipse – > New Android Sample Project创build了一个样例项目,并将Android-support-v7- *项目添加为Eclipse的“Android Project From Existing Code”,并使示例项目引用它们。 但是我在android-support-v7-mediarouter/res/values/styles.xml收到以下错误: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'. (第18行) error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'. (第28行) 我能做些什么来解决这些错误,并build立示例项目?

将drawableLeft与button的文本alignment

这是我的布局: 我面临的问题是可绘制的复选标记。 我将如何去alignment它旁边的文本,他们都集中在button? 这里是XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".PostAssignmentActivity" > <LinearLayout style="?android:attr/buttonBarStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" > <Button style="?android:attr/buttonBarButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:drawableLeft="@drawable/ic_checkmark_holo_light" android:text="Post" /> <Button style="?android:attr/buttonBarButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LinearLayout> </RelativeLayout> 应用android:gravity =“center_vertical”将文本和绘图拉到一起,但是文本不再在中心alignment。