relativelayout

Using Navigation Drawer without TitleBar or ActionBar

眉间皱痕 提交于 2019-11-27 16:40:11
问题 I'm adding a Navigation Drawer to this app that I am developing and I have scoured the internet; forums, stackoverflow, android developer documentation, and still have not found a great answer for this. I know that it is possible to do this without using either of these things. What I am wondering is how. The NsMenuAdapter model uses a title, and then there are these functions getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); Which are clearly looking

扩大小按钮的事件点击范围

荒凉一梦 提交于 2019-11-27 16:17:33
我们在平时的实战开发过程中经常会碰到这样的一些需求,我们要点击一个小按钮弹出一个DialogFragment或者点击之后跳转到另外一个界面上去,我们发现由于按钮太小了不容易点击,这样的体验非常不好,怎么办? 效果图 很多长人肯定会说给View加个Padding就行了嘛,是的这样可以解决问题,但是你有没有想过如果该View有背景图,结果你加了个Padding ,View的背景图变形了,这种情况下通过加Padding加大点击范围的方案就行不通了,如何破解?其实很简单,稍微懂点脑筋就把这个问题解决了,我们给这个小按钮外围包裹一个LinearLayout或RelativeLayout,当我们点击外围的LinearLayout或RelativeLayout的时候把这个事件传递给小按钮问题立马就解决了 关键代码: public class FatArrowView extends RelativeLayout { //拦截事件 @Override public boolean onInterceptTouchEvent(MotionEvent ev) {( http://www.my516.com) Log.v(TAG,"onInterceptTouchEvent start..."); return true; } //把事件分发给我们的子View CheckBox @Override

Setting parameters on child views of a RelativeLayout

让人想犯罪 __ 提交于 2019-11-27 15:19:10
I'm having trouble finding exactly the syntax I need to use to set the paramters on child views of a relative layout. I have a root relative layout that I want to set 2 child textviews next to each other like this ---------- --------- | Second | | First | ---------- --------- So I have public class RL extends RelativeLayout{ public RL(context){ TextView first = new TextView(this); TextView second = new TextView(this); first.setText('First'); first.setId(1); second.setText('Second'); second.setId(2); addView(first, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP

Zoom Content in a RelativeLayout

我的未来我决定 提交于 2019-11-27 11:50:27
问题 I have my application for Android 2.1 where I have a root layout with children's that I can click, move and zoom. Everything is fine, as long as the root layout is not zoomed. I have a setup like this; <ZoomableRelativeLayout ...> // Root, Moveable and zoomable <ImageView ....> <RelativeLayout ...> // Clickable, moveable and zoomable <RelativeLayout ...> // Clickable, moveable and zoomable </ZoomableRelativeLayout> And I like to zoom the content in my ZoomableRelativeLayout . I zoom my

Listview error: “Your content must have a ListView whose id attribute is 'android.R.id.list'”

允我心安 提交于 2019-11-27 09:31:30
I am getting an error in my logcat saying "Your content must have a ListView whose id attribute is 'android.R.id.list'". My code compiles and runs but force closes when I start my listview activity. I've checked on many similar questions, it seems to be a common problem but I am still unable to fix my code. The Declaration: private ListView lv; Context mContext; List mList; String[] testcontacts; MessageView aa = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.firstlist); testcontacts = getResources() .getStringArray

How to place views in a specific location (x, y coordinates)

自作多情 提交于 2019-11-27 06:30:14
问题 I have a problem with placing my views (my class extends View ) in a specific location. I have designed a game that treats the screen as a net of grids. I get from the user x and y coordinates of a specific view (I have different types of views). My first mission is to set the correct view in its place. How can I do it? I am using RelativeLayout for the screen. P.S. I don't want to use AbsoluteLayout params because it was truncated. 回答1: This is not the best way to achieve it, but it's a

Moving from one activity to another Activity in Android

怎甘沉沦 提交于 2019-11-27 03:47:38
I want to move from one activity to another (using virtual device). When I click on button to move, My emulator ones a dialog box showing unfortunately SMS1 has stopped working (SMS1 is my app name). Can anybody help me in correcting my code? MainActivity.java: package com.example.sms1; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity implements OnClickListener

How to have a fixed footer with scrollview in android?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 01:42:34
问题 I have been trying to use Fixed footer not displaying the bottom-most list item but does not work with scrollview . Note i am not using listview but it is a big layouts with images and buttons . The footer should be positioned at the botton always even while user is scrolling . FourSquare has this in their app where there is fixed footer even while scrolling. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill

android 重叠view 重叠布局

情到浓时终转凉″ 提交于 2019-11-27 01:38:25
使用RelativeLayout即可实现重叠布局——RelativeLayout标签内容里面的 下层布局会浮现在上层布局之上;上层布局会被下层布局覆盖 实现layout: <RelativeLayout android:layout_width="match_parent" android:layout_height="200dp" android:background="#FFE4C4"> <LinearLayout android:layout_width="300dp" android:layout_height="100dp" android:background="#303F9F"></LinearLayout> <LinearLayout android:layout_width="200dp" android:layout_height="100dp" android:background="#FF4081" android:layout_marginLeft="50dp" android:layout_marginTop="50dp"></LinearLayout> </RelativeLayout> 实现效果: 来源: CSDN 作者: meixi_android&java 链接: https://blog.csdn.net/meixi_android

Android响应点击事件页面跳转

这一生的挚爱 提交于 2019-11-26 23:44:23
这是我Android学习的第一天,第一堂课的作业是写两个button,分别实现点击显示hello world 和图片消息。 实现代码如下: activity_main.xml: 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.example.zhangqiongwen.homework1.MainActivity" 8 tools:layout_editor_absoluteY="81dp"> 9 10 <include layout="@layout/button"> 11 12 </include> 13 </RelativeLayout> button.xml: 1 <?xml version=