Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。




2
Android ListView选择器颜色
大家好, 关于Android中的ListView,我有2个问题: 如何获取列表视图的重点行的颜色?我尝试使用ListView.getSelector()方法,根据它的文档,该方法应该可以为我提供所需的内容,但是它却为我提供了Drawable对象,我不知道如何从中检索颜色(如果可能的话)。 ..)。 如何设置列表视图的重点行的颜色?在这里,我尝试在列表视图上使用setSelector()方法,并向其传递一个ColorDrawable对象,但是这样做的结果是,列表视图的整个背景都以该颜色绘制了……这不是我想要的当然... 谢谢!

15
如何在Android上使用Git?
我有一个使用git进行同步的桌面应用程序。我还有一个Android应用程序,其功能与桌面相同,但我不知道如何在其上进行同步。我还没有在android上找到git的任何实现。我找到了一个jgit,但是它的记录不完整,因此我什至无法提交。 我当时在考虑从我的android应用程序向我的git服务器发送远程命令,但这对我来说真的很有趣。你能告诉我是否有其他可以在android上使用的git实现?如果您有解决办法的任何想法,请告诉我。





8
在刷新期间使用SwipeRefreshLayout切换片段时,片段会冻结,但实际上仍然可以工作
更新:我认为它工作正常。但是经过一些测试后,问题仍然存在*嗅* 然后,我制作了一个简单的版本,以查看确切发生了什么,并且我知道应该分离的令人耳目一新的片段仍然留在那里。或者恰好是旧片段的视图留在新片段之上。由于我原始应用程序的RecyclerView的背景不是透明的,因此事实证明了我之前所说的。 更新结束 我有这样的MainActivity布局: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- As the main content view, the view below consumes the entire space available using match_parent in both dimensions. --> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- android:layout_gravity="start" tells DrawerLayout to treat this as a sliding drawer on the left side …

3
Android渐变中的angle属性
我正在通过测试示例。对于某些使用渐变的图像背景,代码如下所示 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#ff0000" android:centerColor="#00ff00" android:endColor="#0000ff" android:angle="180"/> <corners android:radius="5dp" /> </shape> 在上面的xml中,我没有获取angle属性。但是当我angle稍微改变图案倾斜的值时。谁能解释一下它是如何工作的?

11
Java-将字符串转换为有效的URI对象
我试图从一个java.net.URI对象String。该字符串包含一些字符,需要用其百分比转义序列替换。但是,当我使用URLEncoder以UTF-8编码对String进行编码时,即使将/替换为其转义序列。 如何从String对象获取有效的编码URL? http://www.google.com?q=a b给出http%3A%2F%2www.google.com ...,而我希望输出为http://www.google.com?q=a% 20b 有人可以告诉我如何实现这一目标。 我正在尝试在Android应用程序中执行此操作。因此,我可以访问数量有限的库。
73 java  android  encoding  utf-8 

5
通函揭示了新活动的过渡
根据https://developer.android.com/training/material/animations.html 该ViewAnimationUtils.createCircularReveal()方法使您可以为剪切圆制作动画以显示或隐藏视图。 要使用此效果显示以前不可见的视图: // previously invisible view View myView = findViewById(R.id.my_view); // get the center for the clipping circle int cx = (myView.getLeft() + myView.getRight()) / 2; int cy = (myView.getTop() + myView.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = Math.max(myView.getWidth(), myView.getHeight()); // …

5
将UI元素的位置/大小设置为屏幕大小的百分比
我正在尝试确定在创建布局时是否可以使用百分比位置/大小。我想要的是这样的... ^ | | | 68% | | v Gallery (height equivalent of 16% total screen size) ^ | 16% v 我正在横向显示800x480实际像素的设备上进行测试,目前正在强制以下操作... <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="80px" android:layout_marginTop ="320px" /> </RelativeLayout> 显然,我不想对固定px单位进行硬编码,但是我不能使用68%或0.68用于layout_marginTop(例如)。我已经看过dp单位了,但是我不确定是否也可以那样做。 我不得不承认UI设计是我的弱点,因此我们将不胜感激任何建议。 编辑:如果有人正在寻找类似的答案,以供将来参考,按照艾伦·摩尔的建议,我可以按照我的意愿进行以下工作... <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@drawable/bground" android:layout_width="fill_parent" android:layout_height="fill_parent" …


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.