我有内容我需要显示在我的列表视图上方和下方,如果你可以一起使用scrollview和listviews,那么滚动视图会很好用.既然那不是最好的解决方案,我一直试图做一些事情来添加页脚内容到我的列表视图,
这里下面的图片显示了当我添加不同类型的行作为最后一行时会发生什么.我无法获取我的内容来填充行的宽度

我有一些需要进入页脚的按钮.我正在使用扩展BaseAdapter的自定义适配器.
我也尝试过使用addFooterView,但是如果你正在实现自己的适配器,我会对如何使用addFooterView方法感到困惑.任何人都有任何关于如何在自定义适配器上实现addFooterView的简单示例
要么
有没有办法让我可以在这个位置获得行(如图所示)以更好地显示,这里是我用来创建这个页脚行的代码
View v = getLayoutInflater().inflate(R.layout.item_listview_footer, null);
LinearLayout ll = (LinearLayout) v.findViewById(R.id.ll);
return ll; // return ll as convertView in getView function
Run Code Online (Sandbox Code Playgroud)
编辑:
这是我的页脚布局的xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="@drawable/red" android:orientation="vertical" android:id="@+id/ll">
<Button android:id="@+id/specialInsButton" style="@style/button" android:text="Add Special Instructions" android:layout_width="fill_parent"/>
<Button android:id="@+id/addToBagButton" style="@style/button" android:text="Add To Bag"/>
<EditText android:id="@+id/quantity" style="@style/standard" android:text="1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是样式/按钮的xml
<style name="button">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:textSize">17px</item>
<item name="android:textStyle">bold</item>
<item name="android:typeface">sans</item>
<item name="android:gravity">center</item>
<item name="android:layout_gravity">center</item>
</style>
Run Code Online (Sandbox Code Playgroud)
标准风格
<style name="standard">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我的xml代码中有一系列嵌套的线性布局.我希望父母的第一个孩子(也是一个线性布局)成为焦点.如果我将focusable设置为true,它就会这样做.我还想把焦点传递给这个布局的子节点(为了调用它们的状态列表).然而,即使它们被设定为可聚焦,它也不会将它的任何焦点传递给它的孩子.任何想法如何做到这一点?谢谢
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:weightSum="1"
android:layout_height="wrap_content"
android:background="@drawable/resultpage_statelist"
android:focusable="true"
android:clickable="true">
<TextView
android:text="TextView"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_weight="0.8"
android:id="@+id/tag_row_text"
android:textSize="16dip"
android:padding="10dip"
android:textColor="@drawable/resultpage_grey_text_statelist"
android:background="#00000000"
android:focusable="true">
</TextView>
<ImageView
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_gravity="right|center_vertical"
android:src="@drawable/arrow_statelist"
android:layout_marginRight="10dip"
android:background="#00000000"
android:focusable="true">
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:background="#6E6E6E"
android:layout_height="1dip">
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我需要在代码中添加一个admob adview到线性布局,但我需要将它插入布局的顶部,而不是底部.
有没有办法做到这一点?
我希望有一个LinearLayout像屏幕一样宽的水平线和它的孩子一样高,但诀窍是它的孩子每个都有动态宽度,我不希望它们离开屏幕(切出).我希望它们在新行中流动/中断,以便它们都可见.
尽管与Android完全无关,但它应该与inline <div>在HTML中的工作方式类似.
这就是我现在所拥有的:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="If you would enter some digits in this field " />
<EditText
android:id="@+id/tvDistance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="enter some digits here"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" that would be great" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但是,一旦LinearLayout比屏幕更宽的孩子,额外的部分离开屏幕/看不见.
布局时我遇到了一个非常奇怪的问题.它看起来像在eclipse XML编辑器和我的三星galaxy中设计但它在我的旧手机xperia x10 mini中搞砸了.我只能假设这也会在其他设备中出现.
如果有人可以帮忙解决这个问题,我将不胜感激.
以下是两个屏幕截图和XML代码.
它在eclipse布局编辑器和我的三星galaxy S4 mini中看起来如何
它在Sony xperia x10 mini中的外观如何
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_marginTop="7dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View android:layout_marginTop="19dp" android:layout_marginLeft="19dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="19dp" android:layout_marginLeft="189dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="18dp" android:layout_marginLeft="20dp" android:layout_height="2dp" android:layout_width="170dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="267dp" android:layout_marginLeft="19dp" android:layout_height="2dp" android:layout_width="171dp" android:background="#B2CFEF"/>
<ImageView style="@style/ta_img" android:id="@+id/ta_lu" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_lc" android:layout_marginTop="124dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ld" android:layout_marginTop="197dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ru" android:layout_marginLeft="170dp" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_rc" android:layout_marginLeft="170dp" android:layout_marginTop="124dp" />
<ImageView …Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-framelayout android-constraintlayout
在我的应用程序中,我将视图动态添加到线性布局.每个视图由一个按钮组成,如果单击该按钮,则视图将被删除.如何刷新线性布局?因为当我删除任何视图时,视图的位置将被更改.
我需要在Android应用程序中创建自己的工具栏.现在它看起来像这样:
所以你看到按钮之间的空格.我试图在按钮上放置负边距/填充,但空间并没有消失.
这是布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/routes_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5">
</ListView>
<TableRow
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="0dp" >
<Button
android:id="@+id/btn_routes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/routes"
android:textSize="10dp" />
<Button
android:id="@+id/btn_places"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/places" />
<Button
android:id="@+id/btn_events"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:textSize="10dp"
android:text="@string/events" />
<Button
android:id="@+id/btn_about"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="0.2"
android:layout_marginRight="-10dp"
android:layout_marginLeft="-10dp"
android:text="@string/about"
android:textSize="10dp" />
</TableRow>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如何删除按钮之间的空间?
我试图围绕我的布局制作边框

但我正在尝试改变布局颜色.没有任何边界.
我的代码是
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<stroke android:width="1dp"
android:color="#eedfcc"
android:background="#000080"/>
<corners android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="10dp"
android:topRightRadius="8dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
为什么它不起作用?
如何以编程方式在"regler"和"decommender"按钮之间设置20dp的余量.

这是我的工作
LinearLayout lytmain = new LinearLayout(Mcontex);
lytmain.setOrientation(LinearLayout.VERTICAL);
LinearLayout lytdate = new LinearLayout(Mcontex);
LinearLayout lytbutton = new LinearLayout(Mcontex);
lytbutton.setBackgroundResource(R.color.black);
lytbutton.setBackgroundResource(R.color.black);
lytdate.setBackgroundResource(R.color.black);
lytmain.setBackgroundResource(R.color.black);
Button btnset = new Button(Mcontex);
Button btncancel = new Button(Mcontex);
btncancel.setShadowLayer(2, 1, 1, R.color.black);
btnset.setShadowLayer(2, 1, 1, R.color.black);
btnset.setBackgroundResource(R.drawable.black_button);
btncancel.setBackgroundResource(R.drawable.black_button);
btnset.setTextColor(Mcontex.getResources().getColor(R.color.white));
btncancel.setTextColor(Mcontex.getResources().getColor(R.color.white));
btncancel.setTextSize(15);
btnset.setTextSize(15);
btnset.setText("Régler");
btncancel.setText("Décommander");
btnset.setGravity(Gravity.CENTER);
btncancel.setGravity(Gravity.CENTER);
final WheelView month = new WheelView(Mcontex);
final WheelView year = new WheelView(Mcontex);
final WheelView day = new WheelView(Mcontex);
lytdate.addView(day, new LayoutParams(
android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1.2f));
lytdate.addView(month, new LayoutParams(
android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.8f)); …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用谷歌和Facebook集成的应用程序...我想修复那些按钮的高度和宽度...我想设置按钮文字手动...
我到目前为止尝试过
<com.facebook.login.widget.LoginButton
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:id="@+id/connectWithFbButton"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/fbloginText"
android:layout_marginTop="30dp"
/>
<com.google.android.gms.common.SignInButton
android:id="@+id/signin"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="@string/googleloginText"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"/>
Run Code Online (Sandbox Code Playgroud)
虽然我已经注意到了这样的事情
fb:login_text="Login"
fb:logout_text="Logout"
or
facebook:login_text="Login"
Run Code Online (Sandbox Code Playgroud)
但我收到错误:: =>在'com.test.b2c'包中找不到属性'login_text'的资源标识符
或通过编码
loginButton = (LoginButton) findViewById(R.id.connectWithFbButton);
loginButton.setText("Login");
Run Code Online (Sandbox Code Playgroud)
现在我的布局看起来像这样

我也想设置这个按钮的高度和宽度.. ...帮助我的朋友..... thx提前
UPDATE
我在设置宽度方面没有直接问题我真正关心的是图片中显示的不一致的HEIGHT.我需要找到更好的方法来使这些按钮高度相同,并将Text设置为那些Button.

android facebook android-linearlayout google-plus android-facebook