Questions tagged «android»

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

4
我如何创建一个帮助叠加层,就像您在一些Android应用程序和ICS中看到的那样?
我想创建帮助叠加层,例如您首次加载ICS时看到的叠加层,或在ES File Explorer或Apex Launcher等应用程序中看到的叠加层(还有更多,但我现在想不起来)。这只是一个相对视图,一个视图位于另一个视图之上吗?我还没有找到执行此操作的任何示例代码。有谁知道这是怎么做的或有什么想法?
93 android 

15
Android:Dex无法解析版本52字节代码
我刚切换到Android Studio 2.1,并且在尝试编译以前可以正常使用的应用程序时出现了此错误: Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' …

7
如何以编程方式将字体自定义字体设置为Spinner文本?
我的资产文件夹中有一个ttf字体文件。我知道如何通过以下方式将其用于textviews: Typeface externalFont=Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeueLTCom-Lt.ttf"); textview1.setTypeface(externalFont); 我已经在自己的xml文件中定义了微调框文本的外观(与android中的通常情况一样): <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+android:id/text1" style="?android:attr/spinnerItemStyle" android:singleLine="true" android:textColor="#ffffff" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ellipsize="marquee" /> 我只是不能从代码引用此textview,我总是得到空指针异常。例如,我尝试过: TextView spinner_text=(TextView)findViewById(R.id.text1); spinner_text.setTypeface(externalFont); 是否可以为我自己的xml中定义的微调框文本选择外部字体? 谢谢。 编辑答案: 这有效: String [] items = new String[2]; items[0]="Something1"; items[1]="Something2"; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinaca, items) { public View getView(int position, View convertView, …

4
如何配置我的Android应用程序?[关闭]
已关闭。这个问题需要更加集中。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅通过编辑此帖子来关注一个问题。 4年前关闭。 改善这个问题 我需要找到Android应用程序中的瓶颈所在。 我可以使用哪些配置文件工具或技术?

6
CollapsingToolbarLayout无法识别滚动
我创建了一个简单的CollapsingToolbarLayout,它的工作原理很像。我的问题是,如果我尝试在nestedscrollview上使用浮动滚动,则在松开手指时滚动将停止。正常的滚动工作应该像它应该的那样。 我的活动代码未更改=>自动生成的空活动。(我只是单击了在android studio中创建新的空活动并编辑了XML)。 我在这里读到,imageview上的滚动手势本身是错误的,但不是,滚动本身是错误的:请参见此处。 我尝试通过Java代码激活“平滑滚动”。似乎如果我滚动到足够远以至于图像视图不再可见,则可以识别出挥动手势。 TLDR:为什么只要可见图像视图,挥动手势就不起作用?我的XML代码如下所示: <android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/profile_app_bar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/profile_collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginStart="48dp" app:expandedTitleMarginEnd="64dp" android:fitsSystemWindows="true"> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="420dp" android:scaleType="centerCrop" android:fitsSystemWindows="true" android:src="@drawable/headerbg" android:maxHeight="192dp" app:layout_collapseMode="parallax"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:layout_collapseMode="pin" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" app:layout_anchor="@id/profile_app_bar_layout" app:layout_anchorGravity="bottom|right|end" android:layout_height="@dimen/fab_size_normal" …

14
PopupWindow-在外部单击时关闭
我的活动上有一个PopupWindow,问题是即使我与活动进行交互(例如,滚动列表),我的PopupWindow仍然显示。我可以滚动浏览列表,而PopupWindow仍然存在。 我想要实现的是当我在非PopupWindow的屏幕上触摸/滚动/单击/等等时,我想关闭PopupWindow。就像菜单如何工作一样。如果您在菜单外单击,该菜单将被关闭。 我已经尝试过了,setOutsideTouchable(true)但不会关闭窗户。谢谢。


16
Android:如何在某些活动中隐藏ActionBar
我开发了一个简单的演示应用程序,其中包含启动屏幕,地图和一些常规屏幕。 我在顶部有一个包含徽标的操作栏。在我的手机(Galaxy s1 I9000 V2.3)上一切看起来都不错,但是当我在Galaxy s2 v4上对其进行测试时,动作栏也会出现在初始屏幕和地图屏幕中。 spalsh和map活动甚至都没有从ActionBarActivity继承,所以这怎么可能?我如何使它消失? 表现: <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:theme="@style/Theme.AppCompat.Light" > <activity android:name=".HomeActivity" android:icon="@drawable/android_logo" android:label="" android:logo="@drawable/android_logo" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name=".MapActivity" android:label="" > </activity> <activity android:name=".PackageActivity" android:icon="@drawable/android_logo" android:label="" android:logo="@drawable/android_logo" > </activity> <activity android:name=".SplashActivity" android:label="" > <intent-filter> <action android:name="android.intent.action.MAIN" …

22
未经授权的Android ADB设备
组态: Windows 8.1 亚行版本:1.0.32 智能手机:一加 问题 据说我安装了三星驱动程序。当我运行ADB设备命令时,它表示未授权。 已经尝试过: 我已经完成了这篇文章所说的所有事情:https : //stackoverflow.com/a/25546300/1848376 但是问题是我没有接到电话提示我必须接受连接。 当我运行命令时adb shell,这是答案: error: device unauthorized. This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong. Otherwise check for a confirmation dialog on your device. 我做了“ adb kill-server”,但是没有任何改变。为什么?

8
有没有办法让ellipsize =“ marquee”总是滚动?
我想在TextView上使用选取框效果,但是仅在TextView获得焦点时才滚动文本。这是一个问题,因为就我而言,这不可能。 我在用: android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" 有没有办法让TextView始终滚动其文本?我已经在Android Market应用程序中看到了这一点,即使该应用程序名称没有得到关注,该应用程序的名称也会在标题栏中滚动,但是我找不到API文档中提到的内容。

7
开放式Android笔画?
是否可以创建仅在某些侧面具有笔触的Android形状对象? 例如,我有: <stroke android:width="3dip" android:color="#000000" android:dashWidth="10dip" android:dashGap="6dip" /> 类似于以下CSS: border: 3px dashed black; 如何仅在一侧设置行程?这就是我在CSS中的做法: border-left: 3px dashed black; 您如何在Android XML中做到这一点?

11
在Appcompat 21中更改工具栏颜色
我正在测试新的Appcompat 21 Material Design功能。因此,我创建了这样的工具栏: <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_my_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/> 并将其包含在我的主布局文件中。 然后像这样将其设置为supportActionBar: Toolbar toolBar = (Toolbar)findViewById(R.id.activity_my_toolbar); setSupportActionBar(toolBar); 它正在工作,但是以某种方式我无法弄清楚如何自定义工具栏。它是灰色的,上面的文字是黑色。如何更改背景和文字颜色? 我已经阅读了以下说明: http://android-developers.blogspot.de/2014/10/appcompat-v21-material-design-for-pre.html 我要监督什么来改变颜色? <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="android:windowActionBar" tools:ignore="NewApi">false</item> <item name="windowActionBar">false</item> </style> 编辑: 通过将以下代码行添加到主题,我能够更改背景色: <item name="colorPrimary">@color/actionbar</item> <item name="colorPrimaryDark">@color/actionbar_dark</item> 但是它们不会影响文本颜色。我想念什么?我更喜欢白色文本和白色菜单按钮,而不是黑色文本和黑色菜单按钮:

26
如何获取Android 4.0+的外部SD卡路径?
三星Galaxy S3具有一个外部SD卡插槽,该插槽安装在上/mnt/extSdCard。 我怎么能通过类似的东西走这条路Environment.getExternalStorageDirectory()? 这将返回mnt/sdcard,而我找不到外部SD卡的API。(或某些平板电脑上的可移动USB存储设备。)



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.