我Error parsing XML: unbound prefix在这个xml文件中有一个:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sipLabel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<ImageView android:src="@drawable/connected" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="0.35" android:gravity="center"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
错误在于<ImageView>.可能是什么问题呢?
非常感谢你.
我想要一个解析任何类型的XMl响应的公共Parser.目前我正在使用XmlPullParser ..其中我从webservice传递xmlresponse并检查XmlPullParser.START_TAG并相应地将数据存储在Beans对象中.
为此,我正在为我正在解析的每个web服务创建一个bean,一个解析器.
我通过iOS App上的一个常见解析器,将所有开始标记作为数组输入到任何Web服务并将数据存储在键值对中,并提供一个包含所有数据的对象..因此无需创建Bean和Parser分别..
在我的项目中,我需要为视图设置始终常量ID.我的意思是不同应用程序版本之间的ID是不变的.经过一些调查后,我发现它可以通过使用来实现,values/public.xml并且该文件中声明的任何id在将来的构建中都不会改变.现在的问题是我无法在某些布局文件中定义视图的id.这是我的layout.xml,其中包含一个带有Id的ImageView,应该将其添加到public.xml:
<?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="wrap_content"
android:background="@drawable/menu_item_selector" >
<ImageView
android:id="@+id/index_row_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/padding_small" />
<ImageView
android:id="@+id/index_row_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/index_row_search" />
<TextView
android:id="@+id/index_row_caption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/index_row_icon"
android:layout_toRightOf="@id/index_row_search"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge" />
Run Code Online (Sandbox Code Playgroud)
这是public.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<public type="string" name="no_internet" id="0xAA0a0001" />
<public type="id" name="index_row_search" id="0xAA0b0015" />
</resources>
Run Code Online (Sandbox Code Playgroud)
eclipse在我添加id"index_row_search"的行上显示错误,并说:
error: Public symbol id/index_row_search declared here is not defined!
但正如您在上面的布局文件中看到的,我有一个带有该ID的ImageView.它想知道上面一行的字符串id定义没有错误!
那么,我应该如何在public.xml中定义View的Id?
更改RadioButton的background属性时遇到一些问题
首先,我想在每个单选按钮下创建一个单选按钮组中的三个行
这是下面的代码
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@android:color/black"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radioBtnFirst"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/custom_radiogroup_divider"
android:text="Answer 1"/>
<RadioButton
android:id="@+id/radioBtnTwo"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/custom_radiogroup_divider"
android:text="Answer 2"/>
<RadioButton
android:id="@+id/radioBtnThree"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/custom_radiogroup_divider"
android:text="Answer 3"/>
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
现在在可绘制文件夹中,custom_radiogroup_divider.xml是
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="0.3dp"
android:color="@android:color/black" />
</shape>
Run Code Online (Sandbox Code Playgroud)
但是现在的问题是当我使用背景属性时
单选按钮看起来像文本与单选按钮重叠
我试图在我的应用程序中添加对新材料UI的支持,但我遇到了令人讨厌的情况.
在SDK 14之前,黑色app菜单需要白色图标.从SDK 14开始,Holo灯主题需要黑色图标.现在,当迁移到Material时,我再次需要白色图标.所以基本上我有一个文件夹drawable-hdpi-v11,一个drawable-hdpi-v14和一个drawable-hdpi-v21.drawable-hdpi-v11和drawable-hdpi-v21具有相同的图像,当然Lint警告我,我有相同的资源重复.
我已经研究了别名创建别名资源,但它似乎没有提供我需要的功能.您是否知道获得相同结果的任何方法(SDK <14或SDK> = 21的白色图像,SDK> = 14且SDK <21的黑色图像)而不重复资源?
Android Studio中是否有任何功能可以通过"="符号对齐所有XML属性.我无法找到任何允许这样做的设置.
只是另一种喜欢代码可读性的代码格式狂热分子.
我在我的风格中使用了以下内容来使状态栏透明:
<style name="TransparentStatusBar" parent="ThemeBase">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是现在屏幕顶部有一个阴影,状态栏是:
我怎样才能删除这个阴影?
编辑:
<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/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
app:layout_scrollFlags="scroll|enterAlways"
app:theme="@style/ToolbarTheme"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
Run Code Online (Sandbox Code Playgroud)
活动:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResource());
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_action_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
ToolbarTheme:
<style name="ToolbarTheme" parent="ThemeBase">
<item name="android:textColorPrimary">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义复选框drawable:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="false"
android:drawable="@drawable/ic_checkbox_unchecked" />
<item
android:state_checked="true"
android:drawable="@drawable/ic_checkbox_checked" />
<item
android:drawable="@drawable/ic_checkbox_unchecked" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我用的是这样的:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:button="@drawable/checkbox"
/>
Run Code Online (Sandbox Code Playgroud)
我创建了两个可绘制图像(一个用于未检查,一个用于检查),一个用于每个尺寸(xxxhdpi,xxhdpi等).
但是,我的复选框出现如下:
它为什么这么大?如何将其缩小到20x20dp?
我有一个折叠的工具栏,但我不能为上帝的爱弄清楚为什么它不会改变我想要的颜色,因为它崩溃...这是我的xml代码折叠工具栏.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/FrontierTheme">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:src="@drawable/background"
android:id="@+id/profileView_imageView"/>
<android.support.v7.widget.Toolbar
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="wrap_content"
android:id="@+id/toolbarProfileViewID"
android:minHeight="?attr/actionBarSize"
app:theme="@style/FrontierTheme"
app:layout_collapseMode="pin">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="@color/mainColor"
app:tabMode="scrollable"
app:tabTextColor="@color/white"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tab_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的styles.v21(我在常规styles.xml文件中没有任何内容)
<style name="FrontierTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">#5F021F</item>
<item name="android:colorPrimaryDark">#5E152C</item>
<item name="android:colorAccent">#BCBCBC</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是我的Android清单.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.daprlabs.swipedeck" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="23" /> …Run Code Online (Sandbox Code Playgroud) android android-xml android-toolbar android-collapsingtoolbarlayout
我在自定义列表视图项目中有一个按钮,我正在使用以下可绘制的xml文件:
rounded_corner.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp" android:layout_height="100dp">
<stroke
android:width="1dp"
android:color="#FFFFFF" />
<solid android:color="#002832" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:radius="5dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
我使用了"#002832"颜色作为drawable.现在,我想以编程方式更改可绘制文件的颜色.我怎样才能做到这一点?
请在没有理解问题的情况下停止标记为重复.
我检查了@Ganesh Pokele SO链接anf,它完全不同.
我查了@bizzard提供的链接但无法解决我的问题.
android android-layout android-xml android-adapter android-drawable
android ×10
android-xml ×10
android-collapsingtoolbarlayout ×1
android-view ×1
view ×1
web-services ×1
xml ×1
xml-parsing ×1