Questions tagged «android»

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

3
Android RelativeLayout以编程方式设置“ centerInParent”
我有一个这样的RelativeLayout: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dip"> <Button android:id="@+id/negativeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dip" android:textColor="#ffffff" android:layout_alignParentLeft="true" android:background="@drawable/black_menu_button" android:layout_marginLeft="5dip" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> <Button android:id="@+id/positiveButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20dip" android:textColor="#ffffff" android:layout_alignParentRight="true" android:background="@drawable/blue_menu_button" android:layout_marginRight="5dip" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> </RelativeLayout> 我希望能够以编程方式设置为positiveButton与以下效果相同: android:layout_centerInParent="true" 如何以编程方式进行此设置?


11
RecyclerView-在特定位置获取视图
我有一个与RecyclerView和一起进行的活动ImageView。我正在使用RecyclerView来水平显示图像列表。当我点击在图像上RecyclerView的ImageView在活动中应显示图像的大局观。到目前为止,一切正常。 现在ImageButtons,活动中还有两个:imageButton_left和imageButton_right。当我单击时imageButton_left,中的图像ImageView应左移,并且中的缩略图也RecyclerView应反映此更改。与的情况类似imageButton_right。 我能够旋转ImageView。但是,如何旋转缩略图RecyclerView?我如何获得ViewHolder的ImageView? 码: 活动XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="vertical"> <ImageView android:id="@+id/original_image" android:layout_width="200dp" android:layout_height="200dp" android:scaleType="fitXY" android:src="@drawable/image_not_available_2" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:gravity="center_horizontal" android:orientation="horizontal"> <ImageButton android:id="@+id/imageButton_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:background="@drawable/rotate_left_icon" /> <ImageButton android:id="@+id/imageButton_right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/rotate_right_icon" …


30
java.lang.ClassNotFoundException:在路径dexpathlist上找不到类
我目前正在一个项目中,我必须使用纯本地ndk。当我尝试从Irrlicht引擎源运行helloworld示例时,它起作用了。然后,按照该示例的相同格式尝试在我的项目中使用它。但是我得到了: 03-14 01:40:05.308: E/AndroidRuntime(799): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.irrlicht.example1/android.app.POMActivity}: java.lang.ClassNotFoundException: Didn't find class "android.app.POMActivity" on path: DexPathList[[zip file "/data/app/com.irrlicht.example1-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.irrlicht.example1-2, /system/lib]] 在运行我的项目时。 这是我的main.cpp文件: #include <android/log.h> #include <jni.h> #include <android_native_app_glue.h> #include "android_tools.h" #ifdef _IRR_ANDROID_PLATFORM_ void android_main(android_app* app) { __android_log_print(4 , "pom" , "nothing"); } #万一 在Android.mk中: LOCAL_PATH := $(call my-dir)/.. IRRLICHT_PROJECT_PATH …
139 java  android  c++  android-ndk 

9
FileProvider崩溃-NPE尝试在空字符串上调用XmlResourceParser
这是我的清单的一部分: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.asd" android:versionCode="118" android:versionName="118" > <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" /> <application android:name="com.example.asd.AsdApplication" android:allowBackup="true" android:allowTaskReparenting="true" android:theme="@style/AsdTheme" > ... <provider android:name="com.example.asd.database.hq.ContentProviderDB" android:authorities="ourContentProviderAuthorities" > </provider> <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.asd.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> </provider> ... </application> </manifest> 这是raw / xml / filepaths.xml中的filepaths文件 <?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path …
139 android 

8
Android上的默认文字大小是多少?
我混合了Button和自己的View,在其中使用Paint.setTextSize()设置文本大小。我希望文本大小看起来像按钮上的文本一样。现在,我当然可以将按钮的文本大小设置为例如18sp,并在我的视图中使用18。但是,为了更好地集成,我只是想知道按钮的“正常”文本大小是多少。根据我的测试,它应该类似于12sp,但是我还没有找到任何文档。 保留默认大小会使视图上的文本太小。 也许我应该使用另一种方法来解决这个问题?
139 android  text-size 


19
显示软键盘时是否向上移动布局?
我在RelativeView中有一些元素,其中设置了align bottom属性,当软键盘出现时,这些元素被软键盘隐藏。 我希望它们向上移动,以便如果有足够的屏幕空间,它们将显示在键盘上方,或者使键盘上方的部分可滚动,以便用户仍可以看到元素。 关于如何解决这个问题的任何想法?

13
以编程方式设置区域设置
我的应用程序支持3种(即将出现4种)语言。由于几种语言环境非常相似,因此我想为用户提供在我的应用程序中更改语言环境的选项,例如,意大利人可能更喜欢西班牙语而不是英语。 用户是否有办法在应用程序可用的语言环境中进行选择,然后更改使用的语言环境?我认为为每个Activity设置区域设置不是问题,因为这是在基类中执行的简单任务。

17
以编程方式更改可绘制颜色
我正在尝试通过代码更改白色标记图像上的颜色。我读过下面的代码应该更改颜色,但是我的标记仍然是白色。 Drawable.setColorFilter( 0xffff0000, Mode.MULTIPLY ) 我错过了什么?还有其他方法可以更改res文件夹中可绘制对象的颜色吗?
139 android 

11
首先在孩子的父母上调用removeView()
首先一点背景: 我在scrollview中有一个布局。首先,当用户在屏幕上滚动时,滚动视图将滚动。但是,经过一定数量的滚动后,我将禁用滚动视图上的滚动,将“滚动焦点”移到子布局内的Web视图上。这样,滚动视图会停留,所有滚动事件都将进入其中的Webview。 因此,对于一个解决方案,当达到滚动阈值时,我将从滚动视图中移除子布局并将其放置在滚动视图的父视图中(并使滚动视图不可见)。 // Remove the child view from the scroll view scrollView.removeView(scrollChildLayout); // Get scroll view out of the way scrollView.setVisibility(View.GONE); // Put the child view into scrollview's parent view parentLayout.addView(scrollChildLayout); 总体思路:(->表示包含) 之前:parentlayout-> scrollview-> scrollChildLayout 之后:parentLayout-> scrollChildLayout 上面的代码给了我这个例外: java.lang.IllegalStateException: The specified child already has a parent. You must call …

6
Android:AsyncTask与服务
为什么我在这里阅读有关大多数问题的答案,而有关AsyncTaskLoader的却很多,而对Services却一无所知?是不是只是对服务的了解不是很好,还是不赞成使用它们或它们具有某些不良属性或某些东西?有什么区别? (顺便说一句,我知道还有其他线程,但是没有人真正指出明显的差异,这些差异可以帮助开发人员轻松地确定自己是否更适合使用一个或另一个解决实际问题。)
138 android 

10
精心设计的Android应用程序的开放源代码示例?[关闭]
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,使其成为Stack Overflow 的主题。 6年前关闭。 改善这个问题 您能推荐对分析和学习android编程有价值的开源android应用程序吗? Android开源项目中是否有适合基础学习的应用程序?基本上,我正在寻找带有源代码的UI设计参考的android应用程序。


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.