该类的setView()方法AlertDialog允许为对话框指定自定义视图.是否可以在此自定义视图中包含哪些控件?
此外,如果我们设置自定义视图,我们还可以使用添加按钮setPositiveButton(),setNegativeButton()等?
题:
我怎么能取回头衔?
这是截图(缺少标题):

操作栏设置:
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle("My Title");
actionBar.setIcon(drawable.dropdown_user);
View mLogoView = LayoutInflater.from(this).inflate(R.layout.mLogoView, null);
actionBar.setCustomView(mLogoView);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
Run Code Online (Sandbox Code Playgroud)
mLogoView.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/img_merchant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/infoflex">
</ImageView>
</RelativeLayout >
Run Code Online (Sandbox Code Playgroud)
android android-custom-view actionbarsherlock android-actionbar
如果不涉及layoutParams,是否有另一种方法可以调整大小,折叠或展开视图?我在新的Material Design和新的Android Dialer应用程序的一些视频中看到了动画.Google表示材料可以轻松改变形状,大小,旋转,颜色等......但我找不到任何东西.
有向后兼容性吗?
到目前为止,为了调整大小,折叠或展开视图,我们必须使用layoutParams,例如:
public static void collapse(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 1){
v.setVisibility(View.GONE);
}else{
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
Run Code Online (Sandbox Code Playgroud)
}
以下是我想从新的Google Android Dialer App获得的示例:

我有一个自定义视图,通过使用路径显示星形.此视图按预期工作,但现在我想将其实现转移到新的Google Material建议.
不幸的是elevation取决于凸起的轮廓,我还没有找到解决方案.
您是否知道任何已知的变通方法或任何其他创造性解决方案?

这是我的凹路径:
double outerSize = w / 2;
double innerSize = w / 5;
double delta = 2.0*Math.PI/5.0;
double rotation = Math.toRadians(-90);
double xpos = w/2.0;
double ypos = h/2.0;
mPath = new Path();
mPath.moveTo((float)(outerSize * Math.cos(delta + rotation) + xpos),
(float)(outerSize * Math.sin(delta + rotation) + ypos));
for(int point= 0;point<6;point++)
{
mPath.lineTo((float) (innerSize * Math.cos(delta * (point + 0.5) + rotation) + xpos),
(float) (innerSize * Math.sin(delta * (point + 0.5) + rotation) + …Run Code Online (Sandbox Code Playgroud) android android-custom-view material-design android-5.0-lollipop android-elevation
我正在尝试创建一个复合视图,我可以在XML中设置属性并将它们传递给复合视图中的子项.在下面的代码中,我想设置android:text并将其传递给EditText.
这可以在不必将每个属性设置为自定义属性的情况下实现吗?
Activity.xml:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.app.CustomLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="child_view_text" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
custom_view.xml:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
</merge>
Run Code Online (Sandbox Code Playgroud)
CustomView.java:
public ValidationTextInputLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
View v = inflate(context, R.layout.custom_view, this);
mEditText = (EditText) v.findViewById(R.id.editText);
mTextInputLayout = (TextInputLayout) findViewById(R.id.textInputLayout);
}
Run Code Online (Sandbox Code Playgroud) 我有一个RelativeLayout需要圆形的左上角和右上角.我可以使用XML定义的可绘制背景来实现这一点,其中包含角topLeftRadius和topRightRadius.但是......这RelativeLayout也需要有一个背景,它是一个带有平铺位图和形状组合的图层列表,并且平铺的位图在可绘制的XML中没有角参数.所以我的想法是RelativeLayout用以下代码制作一个:
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
path.reset();
rect.set(0, 0, w, h);
path.addRoundRect(rect, radius, radius, Path.Direction.CW);
path.close();
}
@Override
protected void dispatchDraw(Canvas canvas) {
int save = canvas.save();
canvas.clipPath(path);
super.dispatchDraw(canvas);
canvas.restoreToCount(save);
}Run Code Online (Sandbox Code Playgroud)
可悲的是没有剪辑发生,我期待它剪辑我的RelativeLayout的所有四个角落,但没有任何事情发生."onSizeChanged"和"dispatchDraw"方法都被调用,我测试过.我也试图关闭硬件加速,但它什么也没做.
我RelativeLayout是一个更大的布局的一部分,并且该布局在子类中膨胀FrameLayout,然后该子类在a中使用a行RecyclerView,如果它改变任何东西.
java android android-custom-view android-layout android-view
所以我试图掌握在Android中使用自定义控件.但我的应用程序在尝试创建活动时崩溃了.这是代码:
package com.myApp;
import android.content.Context;
import android.widget.EditText;
import android.view.View;
import android.view.View.OnClickListener;
public class MyEditText extends EditText implements OnClickListener {
public MyEditText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public void FlashBorder()
{
//do some custom action
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText txt = (EditText) v;
txt.selectAll();
}
}
Run Code Online (Sandbox Code Playgroud)
这是布局xml:
<com.myApp.MyEditText
android:id="@+id/edtTaskName"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud) 我想实现与iPhone中相同的功能

我在底部栏中实现了与iPhone相同的自定义Tabhost.我可以为Normal/Selected状态设置两个Icons,但是我需要动态图标,其中包含Image中给出的通知数量.
谢谢
android android-custom-view android-tabhost android-tabactivity
所以我最近迁移到gradle现在我的自定义视图属性返回null
我的项目看起来像这样
--custom_icon_view //保存带有自定义属性的自定义视图的库 - 我的应用程序//这是实际使用自定义视图的主应用程序
在我的布局中,我有如下定义的命名空间:
xmlns:iconview="http://schemas.android.com/lib/be.webelite.iconview"
Run Code Online (Sandbox Code Playgroud)
因为使用apk/res-auto返回错误,无法识别attibutes
这就是我尝试获取在xml中定义的图标名称的方法,这用于完美地工作,但现在它没有.而我改变的只是迁移到gradle.
final TypedArray a = context.obtainStyledAttributes(attrs,be.webelite.iconview.R.styleable.icon);
icon_name = a.getString(be.webelite.iconview.R.styleable.icon_name);
Run Code Online (Sandbox Code Playgroud)
所以我猜我的gradle.build文件导致了问题?
我把库设置为
apply plugin: 'android-library'
Run Code Online (Sandbox Code Playgroud)
结束主应用程序gradle.build为
apply plugin: 'android'
Run Code Online (Sandbox Code Playgroud)
这让我头疼2天了:(任何帮助/提示非常适合.
这是我的gradle文件
http://pastie.org/private/h57o8nanydosq0dtm6eiq
这是文件夹结构
http://pastie.org/private/nvbzomx2zeagdpzt8qqjsq
这是我在xml中声明我的视图的方式
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<!-- tried res-auto didn't work -->
xmlns:iconview="http://schemas.android.com/apk/lib/be.webelite.iconview"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_gray">
<be.webelite.iconview.IconView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
iconview:icon_name="entypo_search"
android:textSize="25dp"/>
Run Code Online (Sandbox Code Playgroud)
IconView> res> values目录中的attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="icon">
<attr name="name" format="string" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个可以ImageView在您的设备上移动的应用程序,例如拖动,当我放置75%ImageView的屏幕外显示Toast例如.我一直在阅读有关MotionEvent和onTouchListener我已经遵循了这一问题,但它并没有说服我.
我目前的代码是:
public class MainActivity extends AppCompatActivity implements View.OnTouchListener {
int windowwidth;
int windowheight;
private ImageView mImageView;
private ViewGroup mRrootLayout;
private int _xDelta;
private int _yDelta;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DisplayMetrics displaymetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
windowwidth = displaymetrics.widthPixels;
windowheight = displaymetrics.heightPixels;
mRrootLayout = (ViewGroup) findViewById(R.id.root);
mImageView = (ImageView) mRrootLayout.findViewById(R.id.im_move_zoom_rotate);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(150, 150);
mImageView.setLayoutParams(layoutParams);
mImageView.setOnTouchListener(this);
}
public boolean onTouch(View view, …Run Code Online (Sandbox Code Playgroud)